// Free for any type of use so long as original notice remains unchanged.
// Report errors to feedback@ashishware.com
//Copyrights 2006, Ashish Patil , ashishware.com
//////////////////////////////////////////////////////////////////////////
//browser detection
var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

//tooltip Position
var offsetX = 0;
var offsetY = 5;
var opacity = 100;
var toolTipSTYLE;

 function open_win()
       {
        var imgvalue= getEl("ctl00_pagePhoto_listImg").options[current_index].value;    
        var newurl  = imgpath+"controls/displayimage.aspx?photo=" + imgvalue;
        var left = parseInt((screen.availWidth/2) - (600/2));
        var top = parseInt((screen.availHeight/2) - (700/2));
        window.open(newurl,'welcome','menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,width=600,height=650,left=' + left + ',top=' + top + 'screenX=' + left + ',screenY=' + top);
       }
       
     //move next
      function move_next() {

        var maxindex = maxlist-1;
        if (current_index < maxindex) { current_index++;}
        else {current_index = maxindex; return;}

        if ((current_index == maxindex) && maxlist > 0 ) {
            //next button
            getEl(imgnext).src=imgpath+"images/nextdisable.gif";
            getEl(imgnext).alt="";
            getEl(imgnext).title="";
            getEl(imgnext).style.cursor ="";

            //back button
            getEl(imgback).src=imgpath+"images/back.gif";
            getEl(imgback).alt="Previous"
            getEl(imgback).title="Previous"
            getEl(imgback).style.cursor ="hand";
            getEl(imgback).style.cursor ="pointer";
        }
        else {
            show_all_button();
        }
       showdetail();
     }  
     // move previous
     function move_previous() 
     {  
        if (current_index >=1) {current_index--; }
        else {current_index = 0; return;}
       
        if (current_index ==0 && maxlist > 1) {
            getEl(imgnext).src=imgpath+"images/next.gif";
            getEl(imgnext).alt="Next";
            getEl(imgnext).title="Next";
            getEl(imgnext).style.cursor ="hand";
            getEl(imgnext).style.cursor ="pointer";
           
            //back button
            getEl(imgback).src=imgpath+"images/backdisable.gif";
            getEl(imgback).alt="";
            getEl(imgback).title="";
            getEl(imgback).style.cursor ="";
        }else {
           show_all_button(); 
        }
        showdetail();
     }
     
     function show_all_button() {
            getEl(imgnext).src=imgpath+"images/next.gif";
            getEl(imgnext).alt="Next";
            getEl(imgnext).title="Next";
            getEl(imgnext).style.cursor ="hand";
            getEl(imgnext).style.cursor ="pointer";
           
            //back button
            getEl(imgback).src=imgpath+"images/back.gif";
            getEl(imgback).alt="Previous"
            getEl(imgback).title="Previous"
            getEl(imgback).style.cursor ="hand";
            getEl(imgback).style.cursor ="pointer";
     }
     
     //display description 
     function showdetail() {
       var title =getEl("ctl00_pagePhoto_listText").options[current_index].text;
       getEl("img1").src = imgpath+"controls/getimage.aspx?size=1&photo=" + getEl("ctl00_pagePhoto_listImg").options[current_index].value;
       pdetail.value = lstdetail.options[current_index].value;   
       pdetail.innerHTML = getEl("ctl00_pagePhoto_listImg").options[current_index].text;   
       ptotal.innerHTML = (current_index+1) + ' of ' + maxlist; 
     }
     
    function getEl(id){
	    if(document.getElementById){ //all DOM browsers
		    return document.getElementById(id);
	    }else if(document.all){ //IE 4 fall-back
		    return document.all[id];
	    }else if(document.layers){ //Netscape 4
		    return document.layers[id];//but that will only find positioned
	    //elements on Netscape 4.
	    }
        return null; //no suitable method exists on this browser.
    }
    
	
function initToolTips(){
  if(document.getElementById){
          toolTipSTYLE = document.getElementById("toolTipLayer").style;
  }
  if(is_ie || is_nav6up)
  {
    toolTipSTYLE.visibility = "visible";
    toolTipSTYLE.display = "none";
    document.onmousemove = moveToMousePos;
  }
}

function moveToMousePos(e)
{
  if(!is_ie){
    x = e.pageX;
    y = e.pageY;
  }else{
    x = event.x + document.body.scrollLeft;
    y = event.y + document.body.scrollTop;
  }

  toolTipSTYLE.left = x + offsetX+'px';
  toolTipSTYLE.top = y + offsetY+'px';
  return true;
}


function toolTip(msg, fg, bg)
{
  if(toolTip.arguments.length < 1) // if no arguments are passed then hide the tootip
  {
    if(is_nav4)
        toolTipSTYLE.visibility = "hidden";
    else
        toolTipSTYLE.display = "none";
  }
  else // show
  {
    if(!fg) fg = "#777777";
    if(!bg) bg = "#ffffe5";
    var content = '<table border="0" cellspacing="0" cellpadding="0" class="toolTip"><tr><td bgcolor="' + fg + '">' +
                                  '<table border="0" cellspacing="1" cellpadding="0"<tr><td bgcolor="' + bg + '">'+
                                  '<font face="sans-serif" color="' + fg + '" size="-2">' + msg +
                                  '</font></td></tr></table>'+
                                  '</td></tr></table>';
   if(is_nav4)
    {
      toolTipSTYLE.document.write(content);
      toolTipSTYLE.document.close();
      toolTipSTYLE.visibility = "visible";
    }

    else if(is_ie || is_nav6up)
    {
      document.getElementById("toolTipLayer").innerHTML = content;
      toolTipSTYLE.display='block'
    }
  }
}



function show(){
	s = '<div class="Text" border="1" style="width:210px; padding:0.5em;">';
	s += getEl("ctl00_pagePhoto_listText").options[current_index].text;;
	s += '</div>'

        toolTip(s)
}


   
