﻿// JScript File

/*----------------------------------------------------------------------------------------------------------------
	Function:	zoomimage(ProdName,ImgHeight,ImgWidth,ImageName)
	Purpose:	function opens the image file passed as a parameter in a popup
	Inputs:		ImgHeight 	number 	Height of the popup window
	            ImgWidth 	number 	Width of the popup window
	            ImageName 	number 	Name of the image file to be displayed 	
	            ProdName    name of the product
---------------------------------------------------------------------------------------------------------------*/


function zoomimage(ProdName,ImgWidth,ImgHeight,ImageName) 
{	
	newwindow = window.open("media.aspx?imgname=" + ImageName + "&prodname=" + ProdName,"_blank","width=" + ImgWidth + ", height=" + ImgHeight + ",top=20,left=75,status=0,resizable=yes,scrollbars=yes");    
    if (window.focus)
	{
		newwindow.focus()
	}	
}


/*****************************************************************************************************************
	Function:	opennewwindow(ProdID,ProdName,ImgWidth,ImgHeight)
	Purpose:	function opens the image file passed as a parameter in a popup
	Inputs:		ImgHeight 	number 	Height of the popup window
	            ImgWidth 	number 	Width of the popup window
	            ImageName 	number 	Name of the image file to be displayed 
	            Filename    Image File path to be displayed in the popup window (URL OF THE PAGE TO OPEN)
******************************************************************************************************************/
function opennewwindow(FileName,ImgWidth,ImgHeight) 
{	
	newwindow = window.open(FileName,"ChildWindow","width=" + ImgWidth + ", height=" + ImgHeight + ",top=50,left=50, scrollbars=1,resizable=yes");
	if (window.focus)
	{
		newwindow.focus()
	}	
}

/*****************************************************************************************************************
	Function:	color1.compareColor(color2)
	Purpose:	function compares two color values. Colors can be in rgb format or hexadecimal format
	Inputs:		color1 	    string 	First color
	            color2  	string 	Second color
	Example:    textbox.style.color.compareColor("#000000")
	            textbox.style.color.compareColor("rgb(102,102,102)")
******************************************************************************************************************/
String.prototype.compareColor = function(){
    if((this.indexOf("#") != -1 && arguments[0].indexOf("#") != -1) || 
      (this.indexOf("rgb") != -1 && arguments[0].indexOf("rgb") != -1)){
      return this.toLowerCase() == arguments[0].toLowerCase()
    }
    else{
      xCol_1 = this;
      xCol_2 = arguments[0];
      if(xCol_1.indexOf("#") != -1)xCol_1 = xCol_1.toRGBcolor();
      if(xCol_2.indexOf("#") != -1)xCol_2 = xCol_2.toRGBcolor();
      return xCol_1.toLowerCase() == xCol_2.toLowerCase()
    }
}


String.prototype.toRGBcolor = function(){
    varR = parseInt(this.substring(1,3), 16);
    varG = parseInt(this.substring(3,5), 16);
    varB = parseInt(this.substring(5,7), 16);
    return "rgb(" + varR + ", " + varG + ", " +  varB + ")";
}
