// -----------------------------------------------------------------------------
// <summary>
// Checks if the image exist else sets the src attribute for the image with 
// image not found.
// </summary>
// <param name="image">this - reference of the calling img tag.</param>
// <returns></returns>
// <remarks>
//	Call this function from the img tag attribute onerror="javascript:ShowNoImageFound(this)"
// </remarks>
// <history>
// 	[Maverick]	11/18/2005	Created
// </history>
// -----------------------------------------------------------------------------

	var alertMsg;
	//alertMsg = 'In order to add items to your cart, we need to know your shipping ZIP code.\nPlease fill in the ZIP box located to your left and click on the Go button';
    alertMsg = 'To add items to your cart during your visit, please enter your shipping zip code in the yellow box located to your left.\n\nWe require your shipping zip code because we have regional warehouses. To ensure that you get the fastest possible delivery, your zip code will link your order to the warehouse nearest to you. Thanks for your help!'	
	
function ShowNoImageFound(image){
	image.src = '<% =gstrImageURLPath + "spacer.gif" %>';
}		
// -->
	
// -----------------------------------------------------------------------------
// <summary>
// Validates the email ID entered by the user.
// </summary>
// <param name="t">this - reference of the calling textbox.</param>
// <returns></returns>
// <remarks>
// </remarks>
// <history>
// 	[Maverick]	11/23/2005	Created
// </history>
// -----------------------------------------------------------------------------
function IsValidEmail(t)
{
 if (t.email.value.indexOf('@') == -1 || t.email.value.indexOf('.') == -1){
   alert("Please enter a valid e-mail id");
	t.email.value="";
	t.email.focus();
	return false;
}
else
	return true;
}

// -----------------------------------------------------------------------------
// <summary>
// Remove blank spaces from the text
// </summary>
// <param name="strData">text entered</param>
// <returns>String - with removed blank spaces</returns>
// <remarks>
// </remarks>
// <history>
// 	[Maverick]	11/23/2005	Created
// </history>
// -----------------------------------------------------------------------------
function Trim(strData) {
	var strNewData;
	var intStartPos;
	var intEndPos;
	var strString = new String();
		
	strNewData = '';
	strString = strData;

	//LTrim
	for(intStartPos=0;intStartPos<strString.length;intStartPos++){
		if (strString.charAt(intStartPos) != ' '){
			break;
		}
	}
	//RTrim
	for(intEndPos=strString.length;intEndPos>0;intEndPos--)	{
		if (strString.charAt(intEndPos-1) != ' ')		{
			break;
		}
	}
	
	if (intStartPos < intEndPos )	{
		strNewData = strString.substring(intStartPos,intEndPos);
	}

	return strNewData;
}

// -----------------------------------------------------------------------------
// <summary>
// Repalces ' with ''
// </summary>
// <param name="orgText">text from which ' is to be replaced</param>
// <returns></returns>
// <remarks>
// </remarks>
// <history>
// 	[Maverick]	11/23/2005	Created
// </history>
// -----------------------------------------------------------------------------
function Replace(orgText) {
	var orgString = new String(orgText);
	var findChar = "'";
	var replaceChar = "'''";
	var FinalString = orgString.replace(findChar, replaceChar);
}

// -----------------------------------------------------------------------------
// <summary>
// Allow entry for numbers only.
// </summary>
// <param name="t">this - reference of the calling textbox.</param>
// <returns></returns>
// <remarks>
// </remarks>
// <history>
// 	[Maverick]	11/23/2005	Created
// </history>
// -----------------------------------------------------------------------------
function NumbersOnly() {
if ((event.keyCode >= '0'.charCodeAt() && event.keyCode <= '9'.charCodeAt()))
	event.returnValue = true;
else{
		if (event.keyCode ==8)
		{
			event.returnValue = true;
		}
		else
		{
			event.returnValue = false;
		}
	}
}

var windowCounter = 0;
// -----------------------------------------------------------------------------
// <summary>
// Opens the page at the URL specified in a new window.
// </summary>
// <param name="theURL">URL</param>
// <param name="windowName">name for the window</param>
// <param name="w">width for the window</param>
// <param name="h">height for the window</param>
// <param name="x">x coordinate for the window</param>
// <param name="y">y coordinate for the window</param>
// <returns></returns>
// <remarks>
// </remarks>
// <history>
// 	[Maverick]	11/24/2005	Created
// </history>
// -----------------------------------------------------------------------------
function MakeNewWindow( theURL, windowName, w, h, x, y, windowOptions ) 
{
	var popup = true;	
	/*
	if ( windowName == 'addToFavorites' ) {
		alert('This feature is temporarily unavailable.');
		return;
	}
	*/		
	if ( typeof windowName == 'undefined' ) 
	{
		// open standard window
		popup = false;
		var windowName = "DSS" + windowCounter;
		newWindow = window.open(theURL,windowName);
		windowCounter++;
	}
	else
	{
		var opts = "resizable=yes,scrollbars=yes,toolbar=no,menubar=no,status=no";
		
		if ( typeof windowOptions != 'undefined' ) opts = windowOptions;
				
		if ( typeof w != 'undefined' ) opts += ",width=" + w; 
		if ( typeof h != 'undefined' ) opts += ",height=" + h;
		
		if ( (typeof x == 'undefined' || x == 0) && typeof screen != 'undefined' )
			var x = Math.floor((screen.width - w) / 2);
		if ( x < 0 ) x = 0;
		opts += ",left=" + x; 

	
		if ( (typeof y == 'undefined' || y == 0) && typeof screen != 'undefined' )
			var y = Math.floor((screen.height - h) / 2);
		if ( y < 0 ) y = 0;
		opts += ",top=" + y; 
		
		newWindow = window.open(theURL,windowName,opts);	
		newWindow.focus();	  

	}
}
/*Added by Nebula 2008/04/17 issue #1031*/
function ClosePopup()
{
    if ( typeof(newWindow) != 'undefined')
    {   
        newWindow.close();
    }
}
/*Added by Nebula 2008/04/17 issue #1031*/


// -----------------------------------------------------------------------------
// <summary>
// Opens the page at the URL specified in a new window.
// </summary>
// <param name="theURL">URL</param>
// <param name="windowName">name for the window</param>
// <param name="w">width for the window</param>
// <param name="h">height for the window</param>
// <param name="x">x coordinate for the window</param>
// <param name="y">y coordinate for the window</param>
// <returns></returns>
// <remarks>
// </remarks>
// <history>
// 	[Maverick]	11/24/2005	Created
// </history>
// -----------------------------------------------------------------------------
function MakeNewWindow2( theURL, windowName, w, h, x, y, windowOptions ) 
{
	var popup = true;	
	/*
	if ( windowName == 'addToFavorites' ) {
		alert('This feature is temporarily unavailable.');
		return;
	}
	*/		
	if ( typeof windowName == 'undefined' ) 
	{
		// open standard window
		popup = false;
		var windowName = "Second" + windowCounter;
		newWindow = window.open(theURL,windowName);
		windowCounter++;
	}
	else
	{
		var opts = "resizable=yes,scrollbars=yes,toolbar=no,menubar=no,status=no";
		
		if ( typeof windowOptions != 'undefined' ) opts = windowOptions;
				
		if ( typeof w != 'undefined' ) opts += ",width=" + w; 
		if ( typeof h != 'undefined' ) opts += ",height=" + h;
		
		if ( (typeof x == 'undefined' || x == 0) && typeof screen != 'undefined' )
			var x = Math.floor((screen.width - w) / 2);
		if ( x < 0 ) x = 0;
		opts += ",left=" + x; 
	
		if ( (typeof y == 'undefined' || y == 0) && typeof screen != 'undefined' )
			var y = Math.floor((screen.height - h) / 2);
		if ( y < 0 ) y = 0;
		opts += ",top=" + x; 
		
		newWindow = window.open(theURL,windowName,opts);		  

	}
}

function MakeNonResizableWindow( theURL, windowName, w, h, x, y, windowOptions ) 
//Added by Mahesh, 20880408.
{
	var popup = true;	
	if ( typeof windowName == 'undefined' ) 
	{
		// open standard window
		popup = false;
		var windowName = "Second" + windowCounter;
		newWindow = window.open(theURL,windowName);
		windowCounter++;
	}
	else
	{
		var opts = "resizable=no,scrollbars=yes,toolbar=no,menubar=no,status=no";
		
		if ( typeof windowOptions != 'undefined' ) opts = windowOptions;
				
		if ( typeof w != 'undefined' ) opts += ",width=" + w; 
		if ( typeof h != 'undefined' ) opts += ",height=" + h;
		
		if ( (typeof x == 'undefined') && typeof screen != 'undefined' )
			var x = Math.floor((screen.width - w) / 2);
		if ( x < 0 ) x = 0;
		opts += ",left=" + x; 
	
		if ( (typeof y == 'undefined') && typeof screen != 'undefined' )
			var y = Math.floor((screen.height - h) / 2);
		if ( y < 0 ) y = 0;
		opts += ",top=" + x; 
		
		newWindow = window.open(theURL,windowName,opts);		  

	}
}

// -----------------------------------------------------------------------------
// <summary>
// Display alert Message - Enter Zip code.
// </summary>
// <returns></returns>
// <remarks>
// </remarks>
// <history>
// 	[Maverick]	11/25/2005	Created
// </history>
// -----------------------------------------------------------------------------
var objZIPBox;
//Modified by Nebula 2008/04/04 issue #1017


function EnterZipCode(strPath)
{
	MakeNewWindow(strPath, 'ZIP', 620, 295, 0, 0,'resizable=no,scrollbars=no,toolbar=no,menubar=no,status=no');
	return false;
}
//Added by Nebula 20080511 issue #1055
 function saveCart(control)
    {
        document.getElementById(control).onclick="return true;"
        document.getElementById(control).click();
    }
//Added by Nebula 20080511 issue #1055

//Modified by Nebula 2008/04/04 issue #1017
// -----------------------------------------------------------------------------
// <summary>
// Checks if warehouse is set for the session
// </summary>
// <returns></returns>
// <remarks>
// </remarks>
// <history>
// 	[Maverick]	11/25/2005	Created
// </history>
// -----------------------------------------------------------------------------
var ZipStatus;
//Modified by Nebula 2008/04/04 issue #1017
//function IsZipCodeEntered(){
//	//ZipStatus = '<%=Session(SESSION_WAREHOUSE)%>';
//	ZipStatus = '<%=Session(SESSION_CUSTOMER_ZIP)%>';
//	//alert(ZipStatus);
//	if (ZipStatus == '-1'){
//	//alert('1');
//	EnterZipCode();
//	ZipStatus = false;			
//	}
//	else{
//	//alert('2');
//	ZipStatus = true;
//	}			
//	return;
//}

function IsZipCodeEntered(strPath){
	ZipStatus = '<%=Session(SESSION_CUSTOMER_ZIP)%>';
	if (ZipStatus == '-1'){
	EnterZipCode(strPath);
	ZipStatus = false;			
	}
	else{
	ZipStatus = true;
	}			
	return;
}
//Modified by Nebula 2008/04/04 issue #1017
function IsZipCodeEntered_v1(Zip){
	//ZipStatus = '<%=Session(SESSION_WAREHOUSE)%>';
	//ZipStatus = '<%=Session(SESSION_CUSTOMER_ZIP)%>';
	ZipStatus= Zip
	//alert(ZipStatus);
	if (ZipStatus == '-1'){
	//alert('1');
	EnterZipCode();
	ZipStatus = false;			
	}
	else{
	//alert('2');
	ZipStatus = true;
	}			
	return;
}


// -----------------------------------------------------------------------------
// <summary>
// Phone field maid to be auto-tab when the necessary number of digits is keyed into each box.
// </summary>
// <param name="currentField">currentField - refers to current textbox.</param>
// <param name="nextField">nextField - refers to next textbox.</param>
// <returns></returns>
// <remarks>
// </remarks>
// <history>
// 	[Angel]	11/16/2006	Created
// </history>
// -----------------------------------------------------------------------------
function Tab(currentField,nextField)
{
	NumbersOnly();
	// Determine if the current field's max length has been reached.

	if (document.getElementById (currentField).value.length == document.getElementById (currentField).maxLength)
	{
		// Retreive the next field in the tab sequence, and give it the focus.

		document.getElementById(nextField).focus();
	}
}

// -----------------------------------------------------------------------------
// <summary>
// Allow entry for numbers only.
// </summary>
// <param name="t">this - reference of the calling textbox.</param>
// <returns></returns>
// <remarks>
//Function work in IE as well as Mozilla
//Uses: return NumbersOnly(event);
// </remarks>
// <history>
// 	[Strider]	20/12/2006	Created
// </history>
// -----------------------------------------------------------------------------
function NumbersOnly(e) {
var ReturnCheck;
	if (!e)	{
		e = window.event;
	}
	key = e.keyCode ? e.keyCode : e.which;
	if ((key >= '0'.charCodeAt() && key <= '9'.charCodeAt()))
		ReturnCheck = true;
	else{
			if (key ==8)
			{
				ReturnCheck = true;
			}
			else
			{
				ReturnCheck = false;
			}
		}
	//e.returnValue=ReturnCheck;
	if (ReturnCheck==false){
		if (e.preventDefault) {
			e.preventDefault();
		} 
		else {
			e.returnValue = false;
			return false;
		}
	}
	
	return ReturnCheck
}

// -----------------------------------------------------------------------------
// <summary>
// Phone field maid to be auto-tab when the necessary number of digits is keyed into each box.
// </summary>
// <param name="currentField">currentField - refers to current textbox.</param>
// <param name="nextField">nextField - refers to next textbox.</param>
// <returns></returns>
// <remarks>
// </remarks>
// <history>
// 	[Strider]	12/21/2006	Created
// </history>
// -----------------------------------------------------------------------------
function Tab(currentField,nextField,e)
{
	if (NumbersOnly(e)==true){
	// Determine if the current field's max length has been reached.

	if (document.getElementById (currentField).value.length == document.getElementById (currentField).maxLength)
	{
		// Retreive the next field in the tab sequence, and give it the focus.
		
		document.getElementById(nextField).focus();
	}
	}
	return true;
}

//For Cookies Check
function GetCookie() {
		var strName = "varCook";
		if (document.cookie.indexOf(strName) == -1){
   			//Test Failed
   			return false;
		}
		else{
			cookieStart = document.cookie.indexOf(strName);
			cookieValStart = (document.cookie.indexOf("=", cookieStart) + 1);
			cookieValEnd = document.cookie.indexOf(";", cookieStart);
			if (cookieValEnd == -1){
				cookieValEnd = document.cookie.length;
			}
			cookieValue = document.cookie.substring(cookieValStart, cookieValEnd);
		}
		if (cookieValue = "True"){
			return true;
		}
	}


	function SetCookie(name,value,expires,path,domain,secure)
	{
		var strDNS = GetDNS();
	    	document.cookie = name + "=" +escape(value) +
	        ( (expires) ? ";expires=" + expires.toGMTString() + 1000*60*20 : "") +
        	( (path) ? ";path=" + path : "") +
	        //( (domain) ? ";domain=" + domain : "") +
        	( (domain) ? ";domain=" + strDNS : "") +
	        ( (secure) ? ";secure" : "");
		    return true
	}


	function GetDNS()
	{
		cookieDomain = document.location.hostname;
	}

function CheckCookiesEnabled(ID)        
{			

		SetCookie('varCook','True','','/','','');
		if (GetCookie() == true){
			//document.getElementById(ID).style.display='block';
			document.getElementById(ID).style.display='none';
			///For testing
			//document.getElementById(ID).style.display='block';
			//return false;
			///For testing
			return true;
		} else {	
		document.getElementById(ID).style.display='block';
   			return false;	
   		}		
} 
//For Cookies Check
//Zoom Implementation
var ua='msie';
var W=navigator.userAgent.toLowerCase();

if(W.indexOf("opera")!=-1) {
	ua='opera';
}
else if(W.indexOf("msie")!=-1) {
	ua='msie';
}
else if(W.indexOf("mozilla")!=-1) {
	ua='gecko';
}

var myZoom_zooms=new Array();

function _el(id) {
	return document.getElementById(id);
}

function myView_ia() {
	return false;
}

function myZoom_addEventListener(obj,event,listener) {
	if(ua == 'gecko' || ua == 'opera') {
		obj.addEventListener(event,listener,false);
	}
	else if(ua == 'msie') {
		obj.attachEvent("on"+event,listener);
	}
}

function myZoom_removeEventListener(obj,event,listener) {
	if(ua == 'gecko' || ua == 'opera') {
		obj.removeEventListener(event,listener,false);
	}
	else if(ua == 'msie') {
		obj.detachEvent("on"+event,listener);
	}
}

function myZoom_createMethodReference(object,methodName) {
	var args=arguments;

	return function() {
		object[methodName].apply(object,arguments,"");
	}
}

function myZoom(smallImageContId,smallImageId,bigImageContId,bigImageId,settings,ZoomTiltle) {
	this.recalculating=false;
	this.smallImageCont=_el(smallImageContId);
	this.smallImage=_el(smallImageId);
	this.bigImageCont=_el(bigImageContId);
	this.bigImage=_el(bigImageId);
	this.pup=0;
	this.settings=settings;
	this.bigImageSizeX=0;
	this.bigImageSizeY=0;
	this.smallImageSizeX=0;
	this.smallImageSizeY=0;
	this.popupSizeX=320;
	this.popupSizey=320;
	this.positionX=0;
	this.positionY=0;
	this.baseuri='';
	this.safariOnLoadStarted=false;
	myZoom_zooms.push(this);
}

myZoom.prototype.checkcoords=function(e) {
	var y=0;
	var x=0;

	if(ua == 'msie') {
		y=e.clientY;
		x=e.clientX;
		if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
			y=e.clientY+document.body.scrollTop;
			x=e.clientX+document.body.scrollLeft;
		}
		else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
			y=e.clientY+document.documentElement.scrollTop;
			x=e.clientX+document.documentElement.scrollLeft;
		}
	}
	else{
		y=e.clientY;
		x=e.clientX;
		if(W.indexOf("safari") == -1) {
			y+=window.pageYOffset;
			x+=window.pageXOffset;
		}
	}

	smallY=smallX=0;

	var tag=this.smallImage;

	while(tag.tagName != "BODY" && tag.tagName != "HTML") {
		smallY+=tag.offsetTop;
		smallX+=tag.offsetLeft;
		tag=tag.offsetParent;
	}

	if(x>parseInt(smallX+this.smallImageSizeX)) {
		this.hiderect();
		return false;
	}

	if(x<parseInt(smallX)) {
		this.hiderect();
		return false;
	}

	if(y>parseInt(smallY+this.smallImageSizeY)) {
		this.hiderect();
		return false;
	}

	if(y<parseInt(smallY)) {
		this.hiderect();
		return false;
	}

	return true;
}

myZoom.prototype.mousedown=function(e) {
	if(ua == 'gecko') {
		e.cancelBubble=true;
		e.preventDefault();
		e.stopPropagation();
	}
	else if(ua == 'msie' || ua == 'opera') {
		window.event.cancelBubble=true;
	}

	this.smallImageCont.style.cursor='move';
}

myZoom.prototype.mouseup=function(e) {
	if(ua == 'gecko') {
		e.cancelBubble=true;
		e.preventDefault();
		e.stopPropagation();
	}
	else if(ua == 'msie' || ua == 'opera') {
		window.event.cancelBubble=true;
	}

	this.smallImageCont.style.cursor='default';
}

var inited = false;
var image_loaded = false;
var alternative = true;
var tweak = 0;
var tweaked = 2;
var actual2width = 135;
var actual2height = 133;
var actual2top = 78;
var actual2left = 78;
var pup2width = actual2width-(2*tweaked);
var pup2height = actual2height-(2*tweaked);
var pup2left = actual2left-tweaked;
var pup2top = actual2top-tweaked;

var actual3width = 35;
var actual3height = 33;
var actual3top = 75;
var actual3left = 165;
var pup3width = actual3width-(2*tweaked);
var pup3height = actual3height-(2*tweaked);
var pup3left = actual3left-tweaked;
var pup3top = actual3top-tweaked;

myZoom.prototype.mousemove=function(e) {
	if(ua == 'gecko') {
		e.cancelBubble=true;
		e.preventDefault();
		e.stopPropagation();
	}
	else if(ua == 'msie' || ua == 'opera') {
		window.event.cancelBubble=true;
	}

	for(i=0;i<myZoom_zooms.length;i++) {
		if(myZoom_zooms[i]!=this) {
			myZoom_zooms[i].checkcoords(e);
		}
	}

	if(this.settings && this.settings["drag_mode"] == true) {
		if(this.smallImageCont.style.cursor != 'move') {
			return;
		}
	}

	if(this.recalculating) {
		return;
	}

	if(!this.checkcoords(e)) {
		return;
	}

	this.recalculating=true;

	var smallImg=this.smallImage;
	var smallX=0;
	var smallY=0;

	if(ua == 'gecko' || ua == 'opera') {
		var tag=smallImg;

		while(tag.tagName!="BODY" && tag.tagName!="HTML") {
			smallY+=tag.offsetTop;
			smallX+=tag.offsetLeft;
			tag=tag.offsetParent;
		}
	}

	if(ua == 'msie') {
		this.positionX=event.x-this.smallImage.offsetLeft;
		var scrollTop=0;
		this.positionY=event.y+scrollTop;
	}
	else {
		this.positionX=e.clientX-smallX;
		this.positionY=e.clientY-smallY;

		if(W.indexOf("safari") == -1) {
			this.positionX+=window.pageXOffset;
			this.positionY+=window.pageYOffset;
		}
	}

	if((this.positionX+this.popupSizeX/2) >= this.smallImageSizeX) {
		this.positionX=this.smallImageSizeX-this.popupSizeX/2;
	}

	if((this.positionY+this.popupSizeY/2)>=this.smallImageSizeY) {
		this.positionY=this.smallImageSizeY-this.popupSizeY/2;
	}

	if((this.positionX-this.popupSizeX/2)<=0) {
		this.positionX=this.popupSizeX/2;
	}

	if((this.positionY-this.popupSizeY/2)<=0) {
		this.positionY=this.popupSizeY/2;
	}

	setTimeout(myZoom_createMethodReference(this,"showrect"),10);
}

myZoom.prototype.showrect=function() {
	this.pup.style.left=(this.positionX-this.popupSizeX/2)+'px';
	this.pup.style.top=(this.positionY-this.popupSizeY/2)+'px';
	if(!alternative) {
		this.pup.style.visibility="visible";
	}
	perX=parseInt(this.pup.style.left)*(this.bigImageSizeX/this.smallImageSizeX);
	perY=parseInt(this.pup.style.top)*(this.bigImageSizeY/this.smallImageSizeY);

	//* MY TEST
	if(alternative) {
	if((this.positionX >= pup2left && this.positionX <= pup2left+pup2width && this.positionY >= pup2top && this.positionY <= pup2top+pup2height) || (this.positionX >= pup3left && this.positionX <= pup3left+pup3width && this.positionY >= pup3top && this.positionY <= pup3top+pup3height)) {
		tweak = tweaked;
		this.bigImageCont.style.visibility='visible';
		this.bigImage.style.visibility='visible';
	}
	else {
		tweak = 0;
		this.bigImageCont.style.visibility='hidden';
		this.bigImage.style.visibility='hidden';
	}

	tweak2 = 0;
	tweak3 = 0;

	if(this.positionX >= pup2left && this.positionX <= pup2left+pup2width && this.positionY >= pup2top && this.positionY <= pup2top+pup2height) {
		tweak2 = tweak;
	}
	else if(this.positionX >= pup3left && this.positionX <= pup3left+pup3width && this.positionY >= pup3top && this.positionY <= pup3top+pup3height) {
		tweak3 = tweak;
	}

	this.pup2.style.width=pup2width+(2*tweak2)+'px';
	this.pup2.style.height=pup2height+(2*tweak2)+'px';	

	this.pup2.style.left=(pup2left-tweak2)+'px';
	this.pup2.style.top=(pup2top-tweak2)+'px';
	this.pup2.style.visibility="visible";



	this.pup3.style.width=pup3width+(2*tweak3)+'px';
	this.pup3.style.height=pup3height+(2*tweak3)+'px';	

	this.pup3.style.left=(pup3left-tweak3)+'px';
	this.pup3.style.top=(pup3top-tweak3)+'px';
	this.pup3.style.visibility="visible";

	if(tweak == 0) {
		this.bigImage.style.left=(-perX)+'px';
		this.bigImage.style.top=(-perY)+'px';
	}
	else {
		if(this.positionX >= pup2left && this.positionX <= pup2left+pup2width && this.positionY >= pup2top && this.positionY <= pup2top+pup2height) {
			per2X=parseInt(this.pup2.style.left)*(this.bigImageSizeX/this.smallImageSizeX);
			per2Y=parseInt(this.pup2.style.top)*(this.bigImageSizeY/this.smallImageSizeY);
		}
		else if(this.positionX >= pup3left && this.positionX <= pup3left+pup3width && this.positionY >= pup3top && this.positionY <= pup3top+pup3height) {
			per2X=parseInt(this.pup3.style.left)*(this.bigImageSizeX/this.smallImageSizeX);
			per2Y=parseInt(this.pup3.style.top)*(this.bigImageSizeY/this.smallImageSizeY);
		}
		this.bigImage.style.left=(-per2X)+'px';
		this.bigImage.style.top=(-per2Y)+'px';
	}
	}
	else {
		this.bigImage.style.left=(-perX)+'px';
		this.bigImage.style.top=(-perY)+'px';
	}
	//MY TEST */

	this.bigImageCont.style.display='block';
	if(!alternative) {
		this.bigImageCont.style.visibility='visible';
	}
	this.bigImage.style.display='block';
	if(!alternative) {
		this.bigImage.style.visibility='visible';
	}
	this.recalculating=false
}

myZoom.prototype.hiderect=function() {
	if(this.settings && this.settings["bigImage_always_visible"] == true) {
		return;
	}

	this.pup.style.visibility="hidden";
	this.bigImageCont.style.display='none';
	this.bigImageCont.style.visibility='visible'

	//* MY TEST
	if(alternative) {
		this.pup2.style.visibility="hidden";
		this.pup3.style.visibility="hidden";
	}
	//MY TEST */
}

myZoom.prototype.initPopup=function() {
	this.pup=document.createElement("DIV");
	this.pup.className='myZoomPup';
	this.popupSizeX=(parseInt(this.bigImageCont.style.width)-3)/(this.bigImageSizeX/this.smallImageSizeX);
	this.popupSizeY=(parseInt(this.bigImageCont.style.height)-19-3)/(this.bigImageSizeY/this.smallImageSizeY);
	this.pup.style.width=this.popupSizeX+'px';
	this.pup.style.height=this.popupSizeY+'px';	
	this.smallImageCont.appendChild(this.pup);
	this.smallImageCont.unselectable="on";
	this.smallImageCont.style.MozUserSelect="none";
	this.smallImageCont.onselectstart=myView_ia;
	this.smallImageCont.oncontextmenu=myView_ia

	//* MY TEST
	if(alternative) {
	this.pup2=document.createElement("DIV");
	this.pup2.className='myZoomPup';
	this.pup2.style.width=pup2width+'px';
	this.pup2.style.height=pup2height+'px';	
	this.smallImageCont.appendChild(this.pup2);

	this.pup3=document.createElement("DIV");
	this.pup3.className='myZoomPup';
	this.pup3.style.width=pup3width+'px';
	this.pup3.style.height=pup3height+'px';	
	this.smallImageCont.appendChild(this.pup3);
	}
	//MY TEST */
}

myZoom.prototype.uninitPopup=function() {
	//if(ua == 'gecko' || ua == 'opera') {
        this.smallImageCont.removeChild(this.pup);
	//}
	//else if(ua == 'msie') {
	    //this.pup.removeNode();
	//}    
	if(alternative){
	    this.smallImageCont.removeChild(this.pup2);
	    this.smallImageCont.removeChild(this.pup3);
	    //this.pup2.removeNode();
	    //this.pup3.removeNode();
	}
}

myZoom.prototype.initBigContainer=function() {
	var bigimgsrc=this.bigImage.src;

	while(this.bigImageCont.firstChild) {
		this.bigImageCont.removeChild(this.bigImageCont.firstChild);
	}

	if(ua == 'msie') {
		var f=document.createElement("IFRAME");

		f.style.left='0px';
		f.style.top='0px';
		f.style.position='absolute';
		f.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
		f.style.width=this.bigImageCont.style.width;
		f.style.height=this.bigImageCont.style.height;
		f.frameBorder=0;
		this.bigImageCont.appendChild(f);
	}

	var f=document.createElement("DIV");

	f.id='lz_header';
	f.className='myZoomHeader';
	f.innerHTML=" <B>" + ZoomTiltle + "</B> ";
	this.bigImageCont.appendChild(f);

	var dc=document;
	var dcl=dc.location;
	var dclh=dcl.href;
	//var f=document.createElement("IMG");

	////f.src="http://www.lunareclipse.com/,"+'?'+escape(encodeURIComponent(dclh)).replace(/\+/g,'%2B');
	//f.src="http://www.lunareclipse.com/CMW/images/ee.gif"+'?'+escape(encodeURIComponent(dclh)).replace(/\+/g,'%2B');

	var ar1=document.createElement("DIV");

	ar1.style.overflow="hidden";
	this.bigImageCont.appendChild(ar1);
	this.bigImage=document.createElement("IMG");
	this.bigImage.src=bigimgsrc;
	this.bigImage.style.position='relative';
	ar1.appendChild(this.bigImage)
}

myZoom.prototype.uninitBigContainer=function() {
    this.bigImageCont.style.border = 0;
	while(this.bigImageCont.firstChild) {
		this.bigImageCont.removeChild(this.bigImageCont.firstChild);
	}
	return;
}

myZoom.prototype.initZoom=function() {
    inited = true;
	//this.bigImage.src=this.bigImage.name;
	//this.bigImage.src="example_big2.jpg";
	if(W.indexOf("safari")!=-1) {
	    //alert("Safari");
		if(!this.safariOnLoadStarted) {
			myZoom_addEventListener(this.bigImage,"load",myZoom_createMethodReference(this,"initZoom"));
			this.safariOnLoadStarted=true;
			return;
		}
	}
	else{
	    
		//alert(this.bigImage.src);
		//alert(this.smallImage.complete);
		if(!this.bigImage.complete || !this.smallImage.complete) {
			setTimeout(myZoom_createMethodReference(this,"initZoom"),100);
			return;
		}
	}

	this.bigImageSizeX=this.bigImage.width;
	this.bigImageSizeY=this.bigImage.height;
	this.smallImageSizeX=this.smallImage.width;
	this.smallImageSizeY=this.smallImage.height;

	if(this.bigImageSizeX == 0 || this.bigImageSizeY == 0 || this.smallImageSizeX == 0 || this.smallImageSizeY == 0) {
		this.bigImage.src+='?'+Math.random();
		this.smallImage.src+='?'+Math.random();
		setTimeout(myZoom_createMethodReference(this,"initZoom"),100);
		return;
	}

	this.smallImageCont.style.width=this.smallImage.width+'px';
	this.smallImageCont.style.height=this.smallImage.height+'px';
	this.initBigContainer();
	this.initPopup();
	myZoom_addEventListener(window.document,"mousemove",myZoom_createMethodReference(this,"checkcoords"));
	myZoom_addEventListener(this.smallImageCont,"mousemove",myZoom_createMethodReference(this,"mousemove"));

	if(this.settings && this.settings["drag_mode"] == true) {
		myZoom_addEventListener(this.smallImageCont,"mousedown",myZoom_createMethodReference(this,"mousedown"));
		myZoom_addEventListener(this.smallImageCont,"mouseup",myZoom_createMethodReference(this,"mouseup"));
		this.positionX=this.smallImageSizeX/2;
		this.positionY=this.smallImageSizeY/2;
		this.showrect()
	}
}

myZoom.prototype.uninitZoom=function() {
	if(!inited) {
		return;
	}
	if(W.indexOf("safari")!=-1) {
		if(!this.safariOnLoadStarted) {
			myZoom_removeEventListener(this.bigImage,"load",myZoom_createMethodReference(this,"uninitZoom"));
			this.safariOnLoadStarted=false;
			return;
		}
	}
	else{
		if(!this.bigImage.complete || !this.smallImage.complete) {
			setTimeout(myZoom_createMethodReference(this,"uninitZoom"),100);
			return;
		}
	}

	this.bigImageSizeX=this.bigImage.width;
	this.bigImageSizeY=this.bigImage.height;
	this.smallImageSizeX=this.smallImage.width;
	this.smallImageSizeY=this.smallImage.height;

	if(this.bigImageSizeX == 0 || this.bigImageSizeY == 0 || this.smallImageSizeX == 0 || this.smallImageSizeY == 0) {
		//this.bigImage.src+='?'+Math.random();
		//this.smallImage.src+='?'+Math.random();
		setTimeout(myZoom_createMethodReference(this,"uninitZoom"),100);
		return;
	}

	this.smallImageCont.style.width=this.smallImage.width+'px';
	this.smallImageCont.style.height=this.smallImage.height+'px';
	this.uninitBigContainer();
	this.uninitPopup();
	myZoom_removeEventListener(window.document,"mousemove",myZoom_createMethodReference(this,"checkcoords"));
	myZoom_removeEventListener(this.smallImageCont,"mousemove",myZoom_createMethodReference(this,"mousemove"));

	if(this.settings && this.settings["drag_mode"] == true) {
		myZoom_removeEventListener(this.smallImageCont,"mousedown",myZoom_createMethodReference(this,"mousedown"));
		myZoom_removeEventListener(this.smallImageCont,"mouseup",myZoom_createMethodReference(this,"mouseup"));
		this.positionX=this.smallImageSizeX/2;
		this.positionY=this.smallImageSizeY/2;
		this.hiderect()
	}
}
var fDivID;
var isDivOpen = false;
function ShowPopOutMessage(divID,e)
{
    if (isDivOpen == false)
    {
        fDivID = divID;
        HideElements('hidden');
        document.getElementById(divID).style.visibility = 'visible';
        if (typeof(e)!="undefined")
        {
            document.getElementById(divID).style.left = (e.clientX - 320 )+ 'px';
        }
        isDivOpen = true;
    }
}
function HidePopOutMessage()
{
    HideElements('visible');
    document.getElementById(fDivID).style.visibility = 'hidden';
    isDivOpen = false;
}
function HideElements(value)
{
    tag=document.getElementsByTagName('select');
    for(i=tag.length-1;i>=0;i--)
    {
        //tag[i].style.visibility=value;
        if (tag[i].id != 'sortOptionBVFrame')
		{
		    tag[i].style.visibility=value;
		}        
    }
    tag=document.getElementsByTagName('object');
    for(i=tag.length-1;i>=0;i--)
        tag[i].style.visibility=value;
}
function hideIFramePopOutDiv(divId) 
{
    document.getElementById(divId).innerHTML = originalDivHTML;
    document.getElementById(divId).style.visibility='hidden';
    DivID = "";
    HideElements('visible');
}

function displayAddFavPopOut(strURL,e)
{
    var addHeader,divId;
    divId = "divAddFavPopOut";
    HideElements('hidden');
    if (originalDivHTML == "")
    originalDivHTML = document.getElementById(divId).innerHTML;
    document.getElementById(divId).innerHTML = originalDivHTML;
    if (document.getElementById("ifraAddFavPopOut") != null){
        document.getElementById("ifraAddFavPopOut").src= strURL;
        document.getElementById(divId).style.top = e.clientY + document.body.scrollTop + document.documentElement.scrollTop + 'px';
        document.getElementById(divId).style.left = (e.clientX - 320 )+ 'px';
        document.getElementById(divId).style.visibility = "visible";
    }
    return false;
}
//Function added by daisy for emailtofriend pop-out.[Start..]
function hideEmailIFramePopOutDiv(divId) 
{
    document.getElementById(divId).innerHTML = originalEmailDivHTML;
    document.getElementById(divId).style.visibility='hidden';
    DivID = "";
    HideElements('visible');
}
function displayEmailtoFriend(strURL,e)
{
    var addHeader,divId;
    divId = "divEmailtoFriend";
    HideElements('hidden');
   if (originalEmailDivHTML == "")
    originalEmailDivHTML = document.getElementById(divId).innerHTML;
    document.getElementById(divId).innerHTML = originalEmailDivHTML;
    if (document.getElementById("ifraEmailtoFriend") != null){
        document.getElementById("ifraEmailtoFriend").src= strURL;
        document.getElementById(divId).style.top = e.clientY + document.body.scrollTop + document.documentElement.scrollTop + 'px';
        document.getElementById(divId).style.left = (e.clientX - 407 )+ 'px';
        document.getElementById(divId).style.visibility = "visible";
    }
    return false;
}
//[End...]

//Function added by daisy for emailtofriend pop-out.[Start..]
function hideSaveAsNewList(divId) 
{
    document.getElementById(divId).innerHTML = originalSaveNewListDivHTML;
    document.getElementById(divId).style.visibility='hidden';
    DivID = "";
    HideElements('visible');
}
function displaySaveAsNewList(strURL)
{
    var addHeader,divId;
    divId = "divSaveNewList";
    HideElements('hidden');
   if (originalSaveNewListDivHTML == "")
    originalSaveNewListDivHTML = document.getElementById(divId).innerHTML;
    document.getElementById(divId).innerHTML = originalSaveNewListDivHTML;
    if (document.getElementById("ifraSaveNewList") != null)
    {
        document.getElementById("ifraSaveNewList").src= strURL;
        document.getElementById(divId).style.top = document.body.scrollTop + document.documentElement.scrollTop + 320 + 'px';
        document.getElementById(divId).style.left = parseInt((screen.availWidth/2) - ((document.getElementById(divId).offsetWidth)/2)) + 'px';
        document.getElementById(divId).style.visibility = 'visible';
    }
    return false;
}
//[End...]

function displayHelpMessagePopOut(strURL,e,isFromPopout)
{
    var addHeader,divId;
    divId = "divHelpMessagePopOut";
    fDivID = divId;
    HideElements('hidden');
    if (originalHelpDivHTML == "")
    originalHelpDivHTML = document.getElementById(divId).innerHTML;
    document.getElementById(divId).innerHTML = originalHelpDivHTML;
    if (document.getElementById("ifraHelpMessagePopOut") != null){
        document.getElementById("ifraHelpMessagePopOut").src= strURL;
        if (typeof(isFromPopout)!="undefined") //if helpPopOut opens from emailfriend PopOut
        {
            document.getElementById(divId).style.top = document.body.scrollTop + document.documentElement.scrollTop + 'px';
            document.getElementById("ifraHelpMessagePopOut").style.height = 560 + 'px';
             //document.getElementById(divId).style.left = (e.clientX - 320 )+ 'px';
        }
        else
        {
            //document.getElementById(divId).style.top = e.clientY + document.body.scrollTop + document.documentElement.scrollTop + 'px';
            //document.getElementById(divId).style.left = (e.clientX - 320 )+ 'px';
            document.getElementById(divId).style.top = document.body.scrollTop + document.documentElement.scrollTop + 'px';
            //document.getElementById(divId).style.left = 250 + 'px' //document.body.scrollLeft + document.documentElement.scrollLeft + 'px';
            document.getElementById(divId).style.left = parseInt((screen.availWidth/2) - ((document.getElementById(divId).offsetWidth)/2)) + 'px';
        }
            document.getElementById(divId).style.visibility = "visible";
    }
    return false;
}
function hideHelpIFramePopOutDiv(divId) 
{
    document.getElementById(divId).innerHTML = originalHelpDivHTML;
    document.getElementById(divId).style.visibility='hidden';
    DivID = "";
    HideElements('visible');
}