﻿// JScript File
function checkBrowser(){
	this.ver=navigator.appVersion
	//alert(this.ver);
	this.dom = document.getElementById?1:0
	this.ie6 = (this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
	this.ie5 = (this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4 = (document.all && !this.dom)?1:0;
	this.ns5 = (this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4 = (document.layers && !this.dom)?1:0;
	this.google =(this.ver.indexOf("Chrome")>-1 && this.dom)?1:0;
	this.bw = (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns5 || this.google);
	return this
}
bw=new checkBrowser()

/*if(bw.ie4 || bw.ie5 || bw.ie6){
    location.href = "newbrowser.htm";
}*/

function placecontent(){
    var sObj = eval(document.getElementById('shell'));
    var cObj = eval(document.getElementById('allcontent'));
    var cw = ( document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth );
    sObj.style.width = (cw - 20) + "px";
    var cox = (cw/2 - (1000/2));
    if(cox < 0){
        cox = 0;
    }
    cObj.style.left = cox + "px";
}

function toggleform(){
    var fObj = eval(document.getElementById('formtbl').style);
    if(fObj.display == "none"){
        fObj.display = "block";
    }else{
        fObj.display = "none";
    }
}

function getcookie(strcname){
    var cstart, cend, cval;
    if(document.cookie.length > 0){
        //alert("1");
        cstart = document.cookie.indexOf(strcname + "=");
        if(cstart != -1){
            //alert("2");
            cstart = cstart + strcname.length + 1;
            cend = document.cookie.indexOf(";", cstart);
            if(cend == -1){
                cend = document.cookie.length;
            }
            cval = unescape(document.cookie.substring(cstart, cend));
            //alert("" + cval);
        }
    }
    return cval;
}

function makepopup(strurl, strwidth, strheight, strparms){
    var parmstr = "";
    if(strwidth != ""){
        parmstr = "width=" + strwidth;
    }
    if(strheight != ""){
        if(parmstr != ""){
            parmstr = parmstr + ",";
        }
        parmstr = parmstr + "height=" + strheight;
    }
   if(strparms != ""){
    parmstr = parmstr + strparms;
   } 
    if(strurl != ""){
        window.open(strurl, "", parmstr);
    }
}

function revealimagetool(strurl){
    document.getElementById('imagetooldiv').style.display = "block";
    document.getElementById('imagetoolframe').src = strurl;
}

var icoArr = new Array();
icoArr[0] = new Array();
icoArr[0][0] = '1';
icoArr[0][1] = 'trout_icon.png';
icoArr[1] = new Array();
icoArr[1][0] = '2';
icoArr[1][1] = 'marlin_icon.png';
icoArr[2] = new Array();
icoArr[2][0] = '2';
icoArr[2][1] = 'tarpon_icon.png';
icoArr[3] = new Array();
icoArr[3][0] = '1';
icoArr[3][1] = 'mayfly_icon.png';
icoArr[4] = new Array();
icoArr[4][0] = '5';
icoArr[4][1] = 'camera_icon.png';
icoArr[5] = new Array();
icoArr[5][0] = '1';
icoArr[5][1] = 'sedge_icon.png';

function openImageCenter(strimg, stricon, e){
    //alert("y: " + gPosY);
    var bObj = document.getElementById('shelloverlay');
    var icObj = document.getElementById('imgcntr');
    var iconObj = document.getElementById('hicon');
    switch(stricon){
        case "1":
        iconObj.src = "/images/site/common/" + getIcon(stricon);
        break;
        case "2":
        iconObj.src = "/images/site/common/" + getIcon(stricon);
        break;
        case "3":
        
        break;
        case "4":
        
        break;
    }
    bObj.style.height = document.body.scrollHeight + "px";
    icObj.style.top = (findY(e) - 450) + "px";
    icObj.style.left = (document.body.clientWidth/2) - 350 + "px";
    icframe.location.href = "largeimg.aspx?strimg=" + strimg;
    bObj.style.display = 'block';
    icObj.style.display = 'block';
}

function openImageGalleryViewer(strimg, stricon, e){
    //alert("y: " + gPosY);
    var bObj = eval(document.getElementById('shelloverlay'));
    var icObj = document.getElementById('imgcntr');
    var iconObj = document.getElementById('hicon');
    switch(stricon){
        case "1":
        iconObj.src = "/images/site/common/" + getIcon(stricon);
        break;
        case "2":
        iconObj.src = "/images/site/common/" + getIcon(stricon);
        break;
        case "3":
        
        break;
        case "4":
        
        break;
    }
    bObj.style.height = document.body.scrollHeight + "px";
    //alert(document.body.scrollHeight);
    icObj.style.top = (findY(e) - 450) + "px";
    icObj.style.left = (document.body.clientWidth/2) - 350 + "px";
    icframe.location.href = "/system/imggalleryviewer.aspx?gid=" + strimg;
    bObj.style.display = 'block';
    icObj.style.display = 'block';
}

function getIcon(stricotype){
    var tmpArr = new Array();
    var cntr = 0, tmppath = "";
    for(i=0; i<icoArr.length; i++){
        if(icoArr[i][0] == stricotype){
            tmpArr[cntr] = new Array();
            tmpArr[cntr][0] = icoArr[i][0];
            tmpArr[cntr][1] = icoArr[i][1];
            cntr++;
        }
    }
    var iInt = Math.round(Math.random() * cntr);
    if(iInt < 0){
        iInt = 0;
    }else if(iInt > (cntr - 1)){
        iInt = (cntr - 1);
    }
    tmppath = tmpArr[iInt][1];
    tmpArr = null;
    return tmppath;
}

function openLogOn(e){
    var bObj = document.getElementById('shelloverlay');
    var icObj = document.getElementById('logdiv');
    
    bObj.style.height = document.body.scrollHeight + "px";
    var strypos = ((findY(e) - 150) - (document.body.clientHeight/2)) + "px"; 
    icObj.style.top = (findY(e) - 150) + "px";//strypos;//(findY(e) - 75) + "px";//(document.body.clientHeight/2) - 75 + "px";
    icObj.style.left = (document.body.clientWidth/2) - 175 + "px";
    logframe.location.href = "/sysedit/ifrlogon.aspx";
    bObj.style.display = 'block';
    icObj.style.display = 'block';
}

function findY(e){
    var tmpY = 0;
    if(e.pageY){
        
        tmpY = e.pageY;
        //alert("tmpY1: " + tmpY);
        
    }else if(e.clientY){
        if(document.documentElement.scrollTop){
            
            tmpY =  e.clientY + document.documentElement.scrollTop;
            //alert("tmpY2: " + tmpY);
        }else{
            
            tmpY = e.clientY + document.body.scrollTop;
            //alert("tmpY3: " + tmpY);
        }
        
    }
    
    if(tmpY <= 350){
            tmpY = 350;
    }
    //alert(tmpY);
    return tmpY;
}

function closeImgCntr(){
    icframe.location.href = "/system/blank.htm";
    var bObj = document.getElementById('shelloverlay');
    var icObj = document.getElementById('imgcntr');
    icObj.style.display = 'none';
    bObj.style.display = 'none';
}
