var myWidth = 0, myHeight = 0;


function bhw() 
{

if( typeof( window.innerWidth ) == 'number' ) {
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
   myWidth = document.body.clientWidth;
   myHeight = document.body.clientHeight;
  }
var h = window.pageYOffset ||
document.body.scrollTop ||
document.documentElement.scrollTop;
var browserName=navigator.appName; 

var imagedivheight=myHeight-93;
var test = myWidth*24/100;
var divwidth = myWidth-test;
var widthformizilla = myWidth-538;
var mozillawidth = widthformizilla-divwidth;
var iewidth = myWidth-516;

var mozillawidth1 = mozillawidth/2;
var iewidth1 = iewidth/2;

var mtop = h+7;
var aboveheight = myHeight-584;
var aboveheight1 = aboveheight/2+h;



document.getElementById('divscroll').style.height="500px";
document.getElementById('divscroll').style.width="504px";
document.getElementById('blwtbl').style.height="478px";
document.getElementById('message2').style.top=aboveheight1+'px';
document.getElementById('message2').style.left=iewidth1+'px';
document.getElementById('divscroll').name="miniwin";



if (myHeight <= 586)
{
document.getElementById('divscroll').style.height=imagedivheight+'px';
document.getElementById('divscroll').style.width="522px";
document.getElementById('blwtbl').style.height=imagedivheight+'px';
document.getElementById('message2').style.top=mtop+'px';

}

}



function max()
{
var imagedivheightnew=myHeight-93;
var imagedivwidthnew=myWidth-212;
var imagedivheightnew1=myHeight-94;


var h = window.pageYOffset ||
document.body.scrollTop ||
document.documentElement.scrollTop;
var browserName=navigator.appName; 
var mtop = h+7;



if (document.getElementById('divscroll').name=="miniwin")
{

document.getElementById('message2').style.left="100px";

document.getElementById('message2').style.top=mtop+'px';
document.getElementById('divscroll').style.width=imagedivwidthnew+'px';
document.getElementById('divscroll').style.height=imagedivheightnew+'px';
document.getElementById('blwtbl').style.height=imagedivheightnew1+'px';
document.getElementById('divscroll').name="maxwin";
document.getElementById('mx').className="doff";
document.getElementById('mx1').className="don";
}

else
	{
document.getElementById('mx').className="don";
document.getElementById('mx1').className="doff";
bhw() 
	}


}






function blowup_show()
{
document.body.style.overflow = "hidden";
document.getElementsByTagName("html")[0].style.overflow = "hidden";

document.getElementById('message2').className="don";
bhw();

}




function blowup_off()
{
document.getElementById('message2').className="doff";
document.body.style.overflow = "";
document.getElementsByTagName("html")[0].style.overflow = "";
}


var path = '';
var imgid = "0";
var queryrfq = '';
function imageset(id)
{


	if(id == dataref.length)
	{
		document.getElementById('next').style.display='none';
		document.getElementById('pre').style.display='block';
	}



	
	else if(id == 1)
	{
		document.getElementById('pre').style.display='none';
		document.getElementById('next').style.display='block';
	}
	else
	{
		document.getElementById('pre').style.display='block';
		document.getElementById('next').style.display='block';
	}
	
	set_big_img_path(id);
//alert(queryrfq);	
	imgid = id;

	var pic = document.getElementById(imgid);
	productName =pic.alt;
	productName = unescape(productName);
	if(productName.length > 40)
        {
		var c = productName.substring(0,40);
		c = c + "...";
		productName = c;
        }
		var alt='';
		if(productName != '' )
	{
		alt='alt="'+productName+'"';
	}
	document.getElementById('imagediv').innerHTML='<img src="'+path+'" onload="loadimg()" ' + alt +'>'; 
document.getElementById('qry').innerHTML=queryrfq;	document.getElementById('prname').innerHTML=productName;


if(dataref.length==1)
	{
		document.getElementById('table_nxt').style.display='none';
	}


}

function nextimg()
{
	if(imgid < dataref.length)
	{
	imgid++;
	}

	if(imgid < dataref.length)
	{
		var newImg = imgid;
		document.getElementById('next').style.display='block';
		document.getElementById('pre').style.display='block';	
	}
	else
	{
		var newImg = imgid;
		document.getElementById('next').style.display='none';
		document.getElementById('pre').style.display='block';
	}
	
	set_big_img_path(newImg);
	

	
	if (document.getElementById(newImg))
	{
		var pic = document.getElementById(newImg);
		productName =pic.alt;
		productName = unescape(productName);
		if(productName.length > 40)
        	{
			var c = productName.substring(0,40);
			c = c + "...";
			productName = c;
        	}


		document.getElementById('imagediv').innerHTML='<img src="'+path+'" onload="loadimg()">'; 
document.getElementById('qry').innerHTML=queryrfq;		document.getElementById('prname').innerHTML=productName;
	}
	else
	{
		var newImg = --imgid;
	}



}

function previousimg()
{
if (imgid  > 1)
{
imgid--;
}


	if (imgid <= 1)
	{
		var newImg = imgid;
		document.getElementById('pre').style.display='none';
		document.getElementById('next').style.display='block';
	}
	else
	{
		var newImg = imgid;
		document.getElementById('pre').style.display='block';
		document.getElementById('next').style.display='block';	
	}
	
	set_big_img_path(newImg);
	

	
	var pic = document.getElementById(newImg);
	productName = pic.alt;
	productName = unescape(productName);
	if(productName.length > 40)
        {
		var c = productName.substring(0,40);
		c = c + "...";
		productName = c;
        }
	document.getElementById('imagediv').innerHTML='<img src="'+path+'" onload="loadimg()">';
	document.getElementById('qry').innerHTML=queryrfq;
	document.getElementById('prname').innerHTML=productName;
}


function set_big_img_path(imgid)
{
	document.getElementById('loadimg').className="don";
	document.getElementById('imagediv').className="doff";

	var k = dataref.length-1;
	if(k >= 0)
	{
		var i = imgid-1;
		path = eval("dataref["+i+"].img_path");

		queryrfq = eval("dataref["+i+"].queryrfq");
	}
}


function keyDown(e)
{var n = (window.Event) ? e.which : e.keyCode;

if(n==9 && document.getElementById('message2').className=="don")
	{
return false;
	}


else if(n==32 && document.getElementById('message2').className=="don")
	{
return false;
	}


else if(n==27 && document.getElementById('message2').className=="don")
	{
blowup_off();
	}

if((n==37 && document.getElementById('message2').className=="don") || (n==38 && document.getElementById('message2').className=="don"))
	{


if (imgid == 1)
{
return false;
}

previousimg();
}

else if((n==39 && document.getElementById('message2').className=="don") || (n==40 && document.getElementById('message2').className=="don"))
	{
if (imgid == dataref.length)
{
return false;
}
nextimg();
return false;
	}
}


function loadimg()
{
document.getElementById('loadimg').className="doff";
document.getElementById('imagediv').className="don";
}


document.write('<div id="message2" STYLE="position: absolute; top: 0px; left: 0px; z-index: 2000; align="center" class="doff"><table id="tableheight" align="center" BORDER="0" CELLPADDING="0" CELLSPACING="0"><tr><td align="center"><table class="bgclor" BORDER="0" CELLPADDING="0" CELLSPACING="0"><tr><td align="center"><table class="main" align="center" BORDER="0" CELLPADDING="0" CELLSPACING="0" width="100%" height="35"><tr><td id="titleBar"  STYLE="cursor:move"><ILAYER width="100%" ONSELECTSTART="return false"> </ILAYER><LAYER width="100%" onmouseover="isHot=true;if (isN4) ddN4(message2)" onmouseout="isHot=false"><div id="prname" class="pr-txt"></div></LAYER></td><td align="right" STYLE="padding-right:0px;" width="100"><table BORDER="0" CELLPADDING="0" CELLSPACING="0"><tr><td><img src="ts/max1.gif" id="mx" width="21" height="21" STYLE="cursor:pointer" onclick="max()" HSPACE="3"></td><td><img src="ts/max.gif" id="mx1" width="21" height="21" STYLE="cursor:pointer;" class="doff" onclick="max()" HSPACE="3"></td><td><img src="ts/cl.gif" width="21" height="21" onclick="blowup_off()" STYLE="cursor:pointer"></td></tr></table></td></tr></table><div STYLE="height: 500px; width: 504px;" class="image_div" id="divscroll" align="center"><table id="blwtbl" align="center" BGCOLOR="#ffffff" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><tr><td align="center"><div id="loadimg" STYLE="font-family: arial; font-size: 15px;" class="doon"><img src="ts/indicator-new.gif"><br><br>Loading...</div><div id="imagediv" class="doff"></div></td></tr></table></div><table class="button" BORDER="0" id="table_nxt" CELLPADDING="0" CELLSPACING="0" width="100%"><tr><td height="22"><img src="ts/zero.gif" width="70" height="1"><br><IMG class="doff" src="ts/back01.gif" style="cursor:pointer" id="pre" onclick="previousimg()" BORDER="0" width="70" height="10" title="Use <- arrow key to view previous image"></td><td width="100%" align="center"><table BORDER="0" CELLPADDING="0" CELLSPACING="0" class="btborder"><tr><td width="5"><img src="ts/blft.gif" width="5" height="27"></td><td BACKGROUND="ts/bgeq.gif" id="qry"></td><td width="5"><img src="ts/brht.gif" width="5" height="27"></td>   </tr></table></td><td align="right"><img src="ts/zero.gif" width="40" height="1"><br><IMG class="don" src="ts/next01.gif" id="next" style="cursor:pointer" onclick="nextimg()" BORDER="0" width="40" height="10" title="Use -> arrow key to view next image"> </td></tr></table></td></tr></table></td></tr></table></div>'); 


isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.message2 : document.getElementById("message2");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}

function dd(e){
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx+'px'; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety+'px';
  return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.message2.visibility="hide";
}

function showMe(){
  if (isIE||isNN) whichDog.style.visibility="visible";
  else if (isN4) document.message2.visibility="show";
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");


