// $Id: scripts.js 125 2005-05-10 08:25:05Z anurag $
// $HeadURL: http://qmail2:8081/svn/im-sw/igp/indiangiftsportal/trunks/diwali/scripts.js $
//<!--
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

condition = !(( (browserName.indexOf("Explorer") >=0 ) && (browserVer < 4) ) ||  ((browserName.indexOf("Netscape") >=0 ) && (browserVer < 2) ) ) ; 

if (condition == true  )
    CanAnimate = true;
else
    CanAnimate = false;

function openchild(thisurl, v_width, v_height,subwindow){
    if (v_width <= 0)   {
        v_width='500';
    }
    if (v_height <= 0)   {
        v_height='500';
    }
	if (subwindow='')
	{
		subwindow = 'subwindow';
	}
    if ( CanAnimate ){ 
        msgWindow=window.open( '' ,subwindow,'left=0,top=0,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=yes,width=' + v_width + ',height=' + v_height);
        msgWindow.focus();
        msgWindow.location.href = thisurl;
    }
    else {
        msgWindow=window.open( thisurl,subwindow,'left=0,top=0,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=yes,width=' + v_width + ',height=' + v_height);
    } 
}

function openchild1(thisurl){
if ( CanAnimate ){ 
        msgWindow=window.open( '' ,'subwindow','toolbar=no,location=no,directories=no,status=yes,scrollbars=no,menubar=no,resizable=yes,width=355,height=390,top=10');
        msgWindow.focus();
        msgWindow.location.href = thisurl;
}
else {
        msgWindow=window.open( thisurl,'subwindow','toolbar=no,location=no,directories=no,status=yes,scrollbars=no,menubar=no,resizable=yes,width=355,height=390,top=10');
}       
}

function openchild2(thisurl){
if ( CanAnimate ){ 
        msgWindow=window.open( '' ,'childwin','toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=yes,width=500,height=450,top=10');
        msgWindow.focus();
        msgWindow.location.href = thisurl;
}
else {
        msgWindow=window.open( thisurl,'childwin','toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=yes,width=500,height=450,top=10');
}       
}

function check_advanced_search(kw)  {
  error = 0;
  if (kw.length < 3) {
    error_message = "Please enter atleast 3 characters for search";
    error = 1;
  }

  if (error == 1) {
    alert(error_message);
    return false;
  } else {
    return true;
  }
}

function goto_url(thisurl) {
	location.href = thisurl;
}
//-->


if (document.getElementById || document.all){
	document.write('<div id="imgtrailer" style="position:absolute; z-index:4;visibility:hidden;"><img src="/gifs/loading.gif"  width="32" height="32"></div>')

}

function gettrailobject()
	{
	if (document.getElementById)
		return document.getElementById("imgtrailer")
	else if (document.all)
		return document.all.trailimagid
	}

function gettrailobj()
	{
	if (document.getElementById)
		return document.getElementById("imgtrailer").style
	else if (document.all)
		return document.all.trailimagid.style
	}

function truebody()
	{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

function hidetrail()
	{
	gettrailobject().innerHTML=" ";
	document.onmousemove='';
	gettrailobj().visibility="hidden";
	}

	function newImage(arg) {
		if (document.images) {
			rslt = new Image();
			rslt.src = arg;
			return rslt;
		}
	}


function trailOn(thumbimg,thh,thw)
	{
		var a = thumbimg; 
		
		gettrailobj().visibility="visible";
		gettrailobj().left="-500px";
		divthw = parseInt(thw) + 2;
		var preloadFlag = false;
		if (document.images) {
			index_1 = newImage(thumbimg);
			preloadFlag = true;
		}
		if (preloadFlag)
		{
			gettrailobject().innerHTML = '<div style="background-color: #FFFFFF; border: 1px solid #B5B5B5; background-repeat: no-repeat; " id="test1"><center><br><br><br><br><img src="/gifs/loading.gif"><br><P STYLE="font-family:arial;color:#000000;font-size:12px;font-weight:bold;"><br><br>loading...</p></center></div><table cellpadding="0" border="0" cellspacing="0" style="background-color: #FFFFFF; height:400px; width:400px; border: 1px solid #B5B5B5; border-right: 2px solid #B2B2B2; border-bottom: 2px solid #B2B2B2; background-repeat: no-repeat;visibility:hidden;" id="test2"><tr><td align="center"><img src="'+a+'" height="'+thh+'" width="'+thw+'" ONLOAD="showmyimg();"></td></tr></table>';
	
			
			divw = parseInt(thw)+25;
			divh = parseInt(thh)+130;
			document.onmousemove=followmouse;
		}
		
	}

function showmyimg()
{
	
 	document.getElementById('test1').style.display="none";
	document.getElementById('test2').style.visibility="visible";

}

function followmouse(e)
	{
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(document.body.offsetHeight, window.innerHeight)
if(typeof e != "undefined")
	{
	if(docwidth < 15+e.pageX+divw)
		xcoord = e.pageX-divw-5;
	else
		xcoord = 15+e.pageX;
	if(docheight < 15+e.pageY+divh)
		ycoord = 15+e.pageY-Math.max(0,(divh + e.pageY - docheight - truebody().scrollTop - 80));
	else
		ycoord = 15+e.pageY;
	}
else if (typeof window.event != "undefined")
	{
	if(docwidth < 15+truebody().scrollLeft+event.clientX+divw)
		xcoord = truebody().scrollLeft-5+event.clientX-divw;
	else
		xcoord = truebody().scrollLeft+15+event.clientX;

	if(docheight < 15+truebody().scrollTop+event.clientY+divh)
		ycoord = 15+truebody().scrollTop+event.clientY-Math.max(0,(divh + event.clientY - docheight - 80));
	else
		ycoord = truebody().scrollTop+15+event.clientY;
	}
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
	}



