// JavaScript code by Joe@TechTailor.com /////////

// note width and height !< 100
// changed default landing page to SKAND on 12-19-2007

var _width = 600;
var _height = 400;
var _innerWidth = 600;
var _innerHeight = 400;
_scrollbar = "yes";
_resizable = "yes";
_menubar = "yes";
_toolbar = "yes";

function toFront()
{
	this.focus();
}

function openInfoWindow()
{
	winAttributes = "'";
	winAttributes += "scrollbar=" + _scrollbar;
	winAttributes += ",width=" + _width;
	winAttributes += ",height=" + _height;
	winAttributes += ",resizable=" + _resizable;
	winAttributes += ",menubar=" + _menubar;
	winAttributes += ",toolbar=" + _toolbar;
	winAttributes += "'";
	alert (winAttributes);
	//newWin=window.open('','infoWindow','scrollbar=yes,width=600,height=400,resizable=yes,menubar=yes,toolbar=yes');
	newWin=window.open('','infoWindow',winAttributes);
	newWin.focus();
}

function openInfoWindow2(scrollbar, width, height, innerWidth, innerHeight, resizable, menubar, toolbar)
{
	winAttributes = "'";
	winAttributes += "scrollbar=" + scrollbar;
	if (width != '')
		winAttributes += ",width=" + width;
	if (height != '')
		winAttributes += ",height=" + height;
	if (innerWidth != '')
		winAttributes += ",innerWidth=" + innerWidth;
	if (innerHeight != '')
		winAttributes += ",innerHeight=" + innerHeight;
	winAttributes += ",resizable=" + resizable;
	winAttributes += ",menubar=" + menubar;
	winAttributes += ",toolbar=" + toolbar;
	winAttributes += "'";	
	//alert (winAttributes);
	//newWin=window.open('','infoWindow','scrollbar=yes,width=600,height=400,resizable=yes,menubar=yes,toolbar=yes');
	newWin=window.open('','infoWindow',winAttributes);
	newWin.focus();
}

function openTimeWindow()
{
	newWin=window.open('','timeWindow','height=100,width=300');
	newWin.focus();
}
function openLoginWindow()
{
	newWin=window.open('','loginWindow','height=210,width=210');
	newWin.focus();
}
function openContactWindow()
{
	newWin=window.open('','contactWindow','height=190,width=250');
	newWin.focus();
}

//added this function 21 NOV 2010
function getQueryVariable(variable) 
{ 
  var query = window.location.search.substring(1); 
  var vars = query.split("&"); 
  for (var i=0;i<vars.length;i++) 
  { 
    var pair = vars[i].split("="); 
    if (pair[0] == variable) 
	{ 
      return pair[1]; 
    } 
  } 
  //return an empty string instead of "undefined"
  return "";
} 

function ttiTrim(local_var)
{
	return local_var.replace(/^\s+|\s+$/g, '') ;
}

//added July 2004:
//modified March 2005 for Jurrens
//modified April 2006 for USA54016
function showParentFrame()
{
	try
	{
		var numOfFrames = parent.frames.length;
		var numOfFramesExpected = 2;
		if(numOfFrames < numOfFramesExpected)
		{
			//added these call on 21 NOV 2010
			prodID_qVar = getQueryVariable("usa_productID");
			 catID_qVar = getQueryVariable("categoryID");
			source_qVar = getQueryVariable("source");
		
			redirectToUrl =  "http://www.SKANDIMPORT.com/?";
			
				if (prodID_qVar > 0)
				{
					redirectToUrl += "productID="  + ttiTrim(prodID_qVar) + "&";
				}
				// if the wrong cat id is passed, it displays an ugly error message
				// for now, skip it 
				//if (catID_qVar > 0)
				//{
				//	redirectToUrl += "categoryID=" +  catID_qVar + "&";
				//}
				if (source_qVar.length > 0) // if not found returns ""
				{
					redirectToUrl += "source="     + ttiTrim(source_qVar) + "&";				
				}
			//alert("redirectToUrl" + redirectToUrl);
			top.location.href = redirectToUrl; 
		}
	}
	catch(e)
	{
		var one = 1;
		//alert(e);
	}
}

//////////////////////////////////////////////////
