﻿/// <reference name="MicrosoftAjax.js"/>

function addEvent(elm, evType, fn, useCapture)
{  
    if (elm.addEventListener){
        elm.addEventListener(evType, fn, useCapture);
        return true;
    }
    else if (elm.attachEvent){
        var r = elm.attachEvent('on' + evType, fn);
        return r
    }
    else{
        elm['on' + evType] = fn;
    }
}

function handleEnter(field, event) {
    var keyCode = document.all ? event.keyCode : event.which; 
    if (keyCode == 13) {
        if ((document.getElementById(field).type == "button") || (document.getElementById(field).type == "submit")) {
            document.getElementById(field).click();
        }
        else {
            document.getElementById(field).focus();
        } 
        return false; 
    } 
    else { 
        return true;
    }
}

function CancelAndClose() {
    window.close();
}

function OpenUserEdit(UserID){
    window.location.href = "UserEdit.aspx?uid=" + UserID;
}

function OpenOrganizationEdit(OrganizationID){
    window.location.href = "OrganizationEdit.aspx?oid=" + OrganizationID;
}

function OpenContentEdit(ContentID, Filters,isSearch){
    window.location.href = "ContentEdit.aspx?cid=" + ContentID + "&fid=" +Filters+ "&isSrc="+isSearch;
}

function OpenContentView(ContentID, Filters){
    window.location.href = "ContentView.aspx?cid=" + ContentID+ "&fid=" +Filters;
}

function OpenContView(ContentID, isSearch){
    window.location.href = "ContentView.aspx?cid=" + ContentID+"&isSrc="+ isSearch;
}

function OpenFileUpLoad(){
    window.open('FileUpLoad.aspx', '', 'width=400 height=300 location=no resizable=no scrollbars=auto');
}

function OpenSupportFileUpLoad() {
    window.open('SupportFileUpLoad.aspx', '', 'width=400 height=300 location=no resizable=no scrollbars=auto');
}

function OpenContentList(Filters){
    window.location.href = "ContentList.aspx?fid=" + Filters;
}

function OpenSearch(OrganizationID){
    window.location.href = "Search.aspx?oid=" + OrganizationID;
}

function OpenContentImageView(ContentID, numImg){
   window.open('ContentImageView.aspx?cid='+ContentID+"&nimg="+numImg, '', 'width=500 height=600 location=no resizable=yes scrollbars=auto'); 
}
function OpenUserList(){
    window.location.href = "UserList.aspx";
}

function OpenOrganizationList(){
    window.location.href = "OrganizationList.aspx";
}
function OpenCategoryList(){
    window.location.href = "CategoryList.aspx";
}
function OpenFileTypesList(){
    window.location.href = "FileTypesList.aspx";
}
function OpenProductTypes(){
    window.location.href = "ProductTypesList.aspx";
}
function OpenReferencesEdit(){
    window.location.href = "ReferencesEdit.aspx";
}
function OpenProductTypesEdit(ProductTypeID){
    window.location.href = "ProductTypesEdit.aspx?pid="+ProductTypeID;
}
function OpenCategoryEdit(CategoryID){
    window.location.href = "CategoryEdit.aspx?cid="+CategoryID;
}
function OpenFileTypesEdit(FileTypeID){
    window.location.href = "FileTypesEdit.aspx?ftid="+FileTypeID;
}
function OpenStatsList(){
    window.location.href = "StatsList.aspx";
}

function OpenPasswordEdit(PasswordId) {
    window.location.href = 'PasswordEdit.aspx?pid=' + PasswordId;
}

function OpenSupportFile(SupportFileId) {
    window.open('SupportFileView.aspx?sfid=' + SupportFileId, '', 'width=500 height=600 location=no resizable=yes scrollbars=yes');
}

function OpenSupportFileLogin() {
    window.open('SupportFileLogin.aspx', '', 'width=300 height=300 location=no resizable=no scrollbars=auto');
}
