function addRow(fieldname,myArray,len,seperator,deletebutton)
{
	
	var a=document.getElementById(fieldname+'table');
	var x = a.insertRow(a.rows.length-1);
	for(var i=0;i<len;i++){      
		var y=x.insertCell(i);
		y.innerHTML=myArray[i].replace('{numberhere}',a.rows.length-2).replace('{numberhere}',a.rows.length-2);
	}
	reNumberRows(fieldname,seperator,deletebutton);
}

function getValue(fieldname,seperator,fseperator)
{
	var dotresult = '';
	if(document.getElementById(fieldname+'table')){
	var a=document.getElementById(fieldname+'table');
	for(var i=1;i<a.rows.length-((seperator=='')?0:1);i++){
		var arow = a.rows[i];
		var rowval = '';
		for(var j=0;j<arow.cells.length;j++){
			var acell = arow.cells[j];  
			var val = '';                    
			if(acell.firstChild){
				val = acell.firstChild.value;
				if(j!=0||seperator==''){
					rowval += val+fseperator;
				}
			}
		}
		dotresult+=rowval+seperator;
	}
	dotresult=dotresult.substring(0,dotresult.length-seperator.length);
	document.getElementById(fieldname).value=dotresult;
	}
}

function deleteRow(i, fieldname,seperator,deletebutton)
{
	var a=document.getElementById(fieldname+'table');
	a.deleteRow(i);
	reNumberRows(fieldname,seperator,deletebutton);
}

function reNumberRows(fieldname, seperator, deletebutton)
{
	var a=document.getElementById(fieldname+'table');
	for(var i=1;i<a.rows.length-((seperator=='')?0:1);i++){
		var arow = a.rows[i];var acell = arow.cells[0];
		acell.innerHTML = '<a href="javascript:deleteRow('+i+',\''+fieldname+'\',\''+seperator+'\',\''+escape(deletebutton)+'\')">'+deletebutton+'</a><br>';
	}            
}

// Funtion to seamlessly call the blah function at the end of the onload
// This causes the footer to position correctly. Still if you deal with 
// any javascript that changes the hieght of the page you will have to 
// recall the blah funtion.

// xHttpRequest r9, Copyright 2006-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

var GlobalXMLREquest;

function sendRequest(url,callback,postData) {
	var req = GlobalXMLREquest = createXMLHTTPObject();
	if (!req) return;
	var method = (postData) ? "POST" : "GET";
	req.open(method,url,true);
	//req.setRequestHeader('User-Agent','XMLHTTP/1.0');
	if (postData)
		req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	req.onreadystatechange = function () {
		if (req.readyState != 4) return;
		if (req.status != 200 && req.status != 304) {
			return;
		}
		callback(req);
	}
	if (req.readyState == 4) return;
	req.send(postData);
}

var XMLHttpFactories = [
	function () {return new XMLHttpRequest()},
	function () {return new ActiveXObject("Msxml2.XMLHTTP")},
	function () {return new ActiveXObject("Msxml3.XMLHTTP")},
	function () {return new ActiveXObject("Microsoft.XMLHTTP")}
];

function createXMLHTTPObject() {
	var xmlhttp = false;
	for (var i=0;i<XMLHttpFactories.length;i++) {
		try {
			xmlhttp = XMLHttpFactories[i]();
		}
		catch (e) {
			continue;
		}
		break;
	}
	return xmlhttp;
}

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
function dirtypop(content)
{
  var generator=window.open('','name','height=400,width=500');
  generator.document.write('<html><head><title>Popup</title>');
  generator.document.write('<link rel="stylesheet" href="css/common.css">');
  generator.document.write('</head><body>');
  generator.document.write('<div style=\'width:100%;height:100%;background-color:#FFFFFF;padding:10px;\'>'+content+'</div>');
  generator.document.write('<p><a href="javascript:self.close()">Close</a></p>');
  generator.document.write('</body></html>');
  generator.document.close();
}
function doit(ele){
	var elex = document.getElementById(ele);
	var elex2 = document.getElementById(ele+"t");
	var elex3 = document.getElementById(ele+"desc");	
	elex2.style.backgroundColor = "gray";
	elex3.style.display="block";
}
function undoit(ele){
	var elex = document.getElementById(ele);
	var elex2 = document.getElementById(ele+"t");
	var elex3 = document.getElementById(ele+"desc");	
	elex2.style.backgroundColor = "white";
	elex3.style.display="none";	
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

function addLoadEvent(func) {   
	var oldonload = window.onload;   
	if (typeof window.onload != 'function') {   
		window.onload = func;   
	} else {   
		window.onload = function() {   
    			oldonload();   
  			func();   
  		}	   
  	}   
}   

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

function positionFooter(offset,num){
	hide('footer');
	var mxid='';
	var mx=0;
	var cur=0;
	for(var i=0;i<=num;i++)
	{
		cur=xPageY(xGetElementById('foot'+i));
		if(cur>mx){mx=cur;mxid='foot'+i;}
	}

	try{
		cur=xPageY(xGetElementById('footex'));
		if(cur>mx){mx=cur;mxid='footex';}
	}catch(err){}

	try{xTop('footer',mx+offset);}
	catch(err){alert(e.message);}
	show('footer');
	
	try{if(xGetElementById('HTF1')){xHeight('HTF1',mx+offset+50-xPageY('HTF1'));}}
	catch(err){alert(err.message);}
	try{if(xGetElementById('HTF2')){xHeight('HTF2',mx+offset+50-xPageY('HTF2'));}}
	catch(err){alert(err.message);}
	try{if(xGetElementById('HTF3')){xHeight('HTF3',mx+offset+50-xPageY('HTF3'));}}
	catch(err){alert(err.message);}
	try{if(xGetElementById('HTF4')){xHeight('HTF4',mx+offset+50-xPageY('HTF4'));}}
	catch(err){alert(err.message);}
	try{if(xGetElementById('HTF5')){xHeight('HTF5',mx+offset+50-xPageY('HTF5'));}}
	catch(err){alert(err.message);}
	try{if(xGetElementById('HTF6')){xHeight('HTF6',mx+offset+50-xPageY('HTF6'));}}
	catch(err){alert(err.message);}
}

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

function setDropDown(ele,val) {
	for(index = 0; index < ele.length; index++) {
		if(ele[index].value == val)
			ele.selectedIndex = index;
	}
}
function toggleCartSize(element){
	var attributes = {
		height: { to: 150 }
	};
	var attributes2 = {
		height: { to: 1 }
	};
	if(document.getElementById(element).style.height=='1px'){
		var anim = new YAHOO.util.Anim(element, attributes, 0.5, YAHOO.util.Easing.bounceOut);
		anim.animate();
	}else{
		var anim = new YAHOO.util.Anim(element, attributes2, 0.5, YAHOO.util.Easing.easeIn);
		anim.animate();
	}
}

function toggleCatalogPageSize(element){
	if(xDisplay(element)=='none'){
		xDisplay(element,'block');
	}else{
		xDisplay(element,'none');
	}
	blah(50);
}

function show(id){
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	} else {
		if (document.layers) {
			document.id.display = 'block';
		} else {
			document.all.id.style.display = 'block';
		}
	}
}

function hide(id){
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	} else {
		if (document.layers) {
			document.id.display = 'none';
		} else {
			document.all.id.style.display = 'none';
		}
	}
}

//show OR hide funtion depends on if element is shown or hidden
function shoh(id) { 
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == "none"){
			document.getElementById(id).style.display = 'block';
			//filter(("img"+id),'imgin');			
		} else {
			//filter(("img"+id),'imgout');
			document.getElementById(id).style.display = 'none';			
		}	
	} else { 
		if (document.layers) {	
			if (document.id.display == "none"){
				document.id.display = 'block';
				//filter(("img"+id),'imgin');
			} else {
				//filter(("img"+id),'imgout');	
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == "none"){
				document.all.id.style.display = 'block';
			} else {
				//filter(("img"+id),'imgout');
				document.all.id.style.display = 'none';
			}
		}
	}
}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}


function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

  if ( results )
    return ( unescape ( results[1] ) );
  else
    return null;
}

// Modal Dialog Box
// copyright 8th July 2006 by Stephen Chapman
// http://javascript.about.com/
// permission to use this Javascript on your web page is granted
// provided that all of the code in this script (including these
// comments) is used without any alteration
function pageWidth() {
    return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}
function pageHeight() {
    return window.innerHeight != null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null;
}
function posLeft() {
    return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}
function posTop() {
    return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}
function $(x) {
    return document.getElementById(x);
}
function scrollFix() {
    var obol = $('ol');
    obol.style.top = posTop() + 'px';
    obol.style.left = posLeft() + 'px'
}
function sizeFix() {
    var obol = $('ol');
    obol.style.height = pageHeight() + 'px';
    obol.style.width = pageWidth() + 'px';
}
function kp(e) {
    ky = e ? e.which : event.keyCode;
    if (ky == 88 || ky == 120) hm();
    return false
}
function inf(h) {
    tag = document.getElementsByTagName('select');
    for (i = tag.length - 1; i >= 0; i--) tag[i].style.visibility = h;
    tag = document.getElementsByTagName('iframe');
    for (i = tag.length - 1; i >= 0; i--) tag[i].style.visibility = h;
    tag = document.getElementsByTagName('object');
    for (i = tag.length - 1; i >= 0; i--) tag[i].style.visibility = h;
}
function sm(obl, wd, ht) {
    var h = 'hidden';
    var b = 'block';
    var p = 'px';
    var obol = $('ol');
    var obbxd = $('mbd');
    obbxd.innerHTML = $(obl).innerHTML;
    obol.style.height = pageHeight() + p;
    obol.style.width = pageWidth() + p;
    obol.style.top = posTop() + p;
    obol.style.left = posLeft() + p;
    obol.style.display = b;
    var tp = posTop() + ((pageHeight() - ht) / 2) - 12;
    var lt = posLeft() + ((pageWidth() - wd) / 2) - 12;
    var obbx = $('mbox');
    obbx.style.top = (tp < 0 ? 0 : tp) + p;
    obbx.style.left = (lt < 0 ? 0 : lt) + p;
    obbx.style.width = wd + p;
    obbx.style.height = ht + p;
    inf(h);
    obbx.style.display = b;
	//document.getElementsByTagName('html').item(0).style.overflow = 'hidden';
    return false;
}
function hm() {
    var v = 'visible';
    var n = 'none';
    $('ol').style.display = n;
    $('mbox').style.display = n;
    inf(v);
    document.onkeypress = ''
	//document.getElementsByTagName('html').item(0).style.overflow = 'auto';	
}
function initmb() {
    var ab = 'absolute';
    var n = 'none';
    var obody = document.getElementsByTagName('body')[0];
    var frag = document.createDocumentFragment();
    var obol = document.createElement('div');
    obol.setAttribute('id', 'ol');
    obol.style.display = n;
    obol.style.position = ab;
    obol.style.top = 0;
    obol.style.left = 0;
    obol.style.zIndex = 1001;
    obol.style.width = '100%';
    frag.appendChild(obol);
    var obbx = document.createElement('div');
    obbx.setAttribute('id', 'mbox');
    obbx.style.display = n;
    obbx.style.position = ab;
    obbx.style.zIndex = 1002;
    var obl = document.createElement('span');
    obbx.appendChild(obl);
    var obbxd = document.createElement('div');
    obbxd.setAttribute('id', 'mbd');
    obl.appendChild(obbxd);
    frag.insertBefore(obbx, obol.nextSibling);
    obody.insertBefore(frag, obody.firstChild);
    window.onscroll = scrollFix;
    window.onresize = sizeFix;
}

function escJSStringInString(stringin){
	stringin = stringin.replace(/'/g,"\\'");
	stringin = stringin.replace(/"/g,'&quot;');
	return stringin;
}

function escJSString(stringin){
	stringin = stringin.replace(/'/g,"\'");
	return stringin;
}

//if(typeof initmb == 'function'){addLoadEvent(function(){initmb();});}
//if(typeof blah == 'function'){addLoadEvent(function(){blah(0);});}
addLoadEvent(function(){blah(0);});