
var minimized = null;
var chosenSCTab = null;
var cartItems = null;


if(document.images){
	but_left = new Image;
	but_left.src = "images/buttom_left.gif";
	but_left2 = new Image;
	but_left2.src = "images/buttom_left_over.gif";
	but_left3 = new Image;
	but_left3.src = "images/buttom_left_rtl.gif";
	but_left4 = new Image;
	but_left4.src = "images/buttom_left_over_rtl.gif";
	but_right = new Image;
	but_right.src = "images/buttom_right.gif";
	but_right2 = new Image;
	but_right2.src = "images/buttom_right_over.gif";
	
	but_help = new Image;
	but_help.src = "images/help_border.gif";
	but_help2 = new Image;
	but_help2.src = "images/help_border2.gif";

	RB = new Image;
	RB.src = "images/radiobutton.gif";
	checkedRB = new Image;
	checkedRB.src = "images/radiobutton_checked.gif";	
	
	SB = new Image;
	SB.src = "images/checkbox.gif";
	selectedSB = new Image;
	selectedSB.src = "images/checkbox_checked.gif";	
	
	maxi = new Image;
	maxi.src = "images/frame_max.gif";
	mini = new Image;
	mini.src = "images/frame_min.gif";	

	buy = new Image;
	buy.src = "images/buttom_left.gif" 
	buyHeb = new Image;
	buyHeb.src = "images/buttom_left_rtl.gif" 
	buyOver = new Image;
	buyOver.src = "images/buttom_left_over.gif" 
	buyOverHeb = new Image;
	buyOverHeb.src = "images/buttom_left_over_rtl.gif" 
	
	rent = new Image;
	rent.src = "images/buttom_right.gif" 
	rentHeb = new Image;
	rentHeb.src = "images/buttom_right_rtl.gif" 
	rentOver = new Image;
	rentOver.src = "images/buttom_right_over.gif" 
	rentOverHeb = new Image;
	rentOverHeb.src = "images/buttom_right_over_rtl.gif" 
}

/**
  * Changes the img_name to new_src 
  */
function changeImages(img_name, new_src)
{
	if(document.images)
		document.images[img_name].src=eval(new_src+".src");
}

function rollOverButton(tag){
	changeImages("br-"+tag,"but_right2");
	var s;
	s = new String(tag);
	if (s.indexOf("rtl",-1)==-1) {
		changeImages("bl-"+tag,"but_left2");
	}else{
		changeImages("bl-"+tag,"but_left4");
	}
	a=document.getElementById("bm-"+tag).className = "button_over";
}

function rollOutButton(tag){
	//changeImages("bl-"+tag,"but_left");
	changeImages("br-"+tag,"but_right");
	var s;
	s = new String(tag);
	if (s.indexOf("rtl",-1)==-1) {
		changeImages("bl-"+tag,"but_left");
	}else{
		changeImages("bl-"+tag,"but_left3");
	}
	a=document.getElementById("bm-"+tag).className = "button";
}

function rollOverButtonH(tag){
	changeImages("bl-"+tag,"but_help2");
	changeImages("br-"+tag,"but_help2");
	a=document.getElementById("bm-"+tag).className = "button_help_over";
}

function rollOutButtonH(tag){
	changeImages("bl-"+tag,"but_help");
	changeImages("br-"+tag,"but_help");
	a=document.getElementById("bm-"+tag).className = "button_help";
}

function indicButton(tag,name,linki){
document.write("<table border='0' cellspacing='0' cellpadding='0' onmouseover=rollOverButton('"+name+"') onmouseout=rollOutButton('"+name+"')>");
  	document.write("<tr>");
    		document.write("<td width='9'><img src='images/buttom_left.gif' width='9' height='17' name='bl-"+name+"'></td>");
		document.write("<a href="+linki+" class='button'><td nowrap style='CURSOR:hand' class='button' id='bm-"+name+"'><a href="+linki+" class='button'>"+tag+"</a></td></a>");
    		document.write("<td width='1'><img src='images/buttom_right.gif' width='1' height='17' name='br-"+name+"'></td>");
  	document.write("</tr>");
document.write("</table>");

}
function indicButton_rtl(tag,name,linki){
document.write("<table border='0' cellspacing='0' cellpadding='0' onmouseover=rollOverButton('"+name+"_rtl') onmouseout=rollOutButton('"+name+"_rtl')>");
  	document.write("<tr>");
    		document.write("<td width='9'><img src='images/buttom_left_rtl.gif' width='9' height='17' name='bl-"+name+"_rtl'></td>");
		document.write("<a href="+linki+" class='button'><td nowrap style='CURSOR:hand' class='button' id='bm-"+name+"_rtl'><a href="+linki+" class='button'>"+tag+"</a></td></a>");
    		document.write("<td width='1'><img src='images/buttom_right.gif' width='1' height='17' name='br-"+name+"_rtl'></td>");
  	document.write("</tr>");
document.write("</table>");

}

/**
  * makes a designed help button (no arrow)
  * @param tag - the button's name and value
  * @param linki - the button's link
  */ 
function indicHelpButton(tag,linki){
document.write("<table border='0' cellspacing='0' cellpadding='0' onmouseover=rollOverButtonH('"+tag+"') onmouseout=rollOutButtonH('"+tag+"')>");
  	document.write("<tr style='line-height:15px;'>");
    		document.write("<td width='1'><img src='images/help_border.gif' width='1' height='15' name='bl-"+tag+"'></td>");
		document.write("<td class='button_help' id='bm-"+tag+"'><a href="+linki+" class='button'>"+tag+"</a></td>");
    		document.write("<td width='1' align='right'><img src='images/help_border.gif' width='1' height='15' name='br-"+tag+"'></td>");
  	document.write("</tr>");
document.write("</table>");
}

function iVBoxImage(ivbox,rowid,hid,gid){
	var x;
	x=new String(ivbox.src);
	if (x.indexOf("checkbox_checked.gif",-1)==-1) {
		ivbox.src=x.replace("checkbox.gif","checkbox_checked.gif");
		document.all.item(hid).value=document.all.item(hid).value+rowid+"|";
		CalcBasketRow(gid);
	}else{
		ivbox.src=x.replace("checkbox_checked.gif","checkbox.gif");
		var y;
		y=new String(document.all.item(hid).value);
		document.all.item(hid).value=y.replace(rowid+"|","");
	}
	CalcBasket();
}

function iCheckBox(o,hid){
	var x;
	x=new String(o.src);
	if (x.indexOf("_checked",-1)==-1) {
		o.src=x.replace("checkbox.gif","checkbox_checked.gif");
		document.all.item(hid).value="true";
	}else{
		o.src=x.replace("checkbox_checked.gif","checkbox.gif");
		document.all.item(hid).value="false";
	}
}

function iRadioImage(gid,qty,iradio,rowid,hid,price,idval){
	var x;
	var h;
	h = new String(document.all.item(hid).value);
	for (i=1;i<=qty;i++){
		x="iRadio_"+gid+"_"+i;
		document.all.item(x).src="images/radiobutton.gif";
		h=h.replace(rowid+">"+i+"|","");
	}
	x="iRadio_"+gid+"_"+iradio;
	document.all.item(x).src="images/radiobutton_checked.gif";
	document.all.item("ship_"+gid).value=price;
	document.all.item(hid).value=h+rowid+">"+idval+"|"
	CalcBasketRow(gid);
	CalcBasket();
	//alert(document.all.item(hid).value);
}


function CalcBasket(){
	var r;
	r = new Number(document.all.item("hidRows").value);
	var t;
	var ot;
	ot= new Number(0);
	for (i=0;i<r;i++){
		var x;
		x= new String(document.all.item("Vbox_"+i).src)
		if (x.indexOf("_checked",-1)==-1) {
			document.all.item("total_"+i).value=" - / - ";
		}else{
			t= new Number(document.all.item("total_"+i).value);
			ot=ot+t;
		}
	}
	document.all.item("sc_total1").value=ot.toFixed(1);
	document.all.item("sc_total2").value=ot.toFixed(1);
}

function CalcBasketRow(row){
	var p;
	p= new Number(document.all.item("price_"+row).value);
	var s;
	s= new Number(document.all.item("ship_"+row).value);
	var q;
	q= new Number(document.all.item("units_"+row).value);
	var str;
	str = new String(s+p*q)
	if (str.indexOf(".")==-1){
		document.all.item("total_"+row).value=str+".0";
	}else{
		document.all.item("total_"+row).value=str.substring(0,str.indexOf(".")+2);
	}
}

function ChangeUnits(rowid,r,hid){
	CalcBasketRow(r);
	var q;
	q= new Number(document.all.item("units_"+r).value);
	document.all.item(hid).value=document.all.item(hid).value+rowid+">"+q+"|";
	CalcBasket();
}

/**
  * chooses a shopping cart tab
  * @param tag - the tab's name
  * @param linki - tab's link
  */ 
function chooseSCTabs(tag,linki,opt){
	if(chosenSCTab!=null){
		unChooseSCTabs(chosenSCTab);
		chosenSCTab = null;
	}
	document.all.item("hidShow").value=opt;
	tag.className = "sc_tabs_chosen";
	chosenSCTab = tag;
	if(linki!=""){
		top.mainFrame.location = linki;
	}
}

/**
  * makes a shopping cart tab not chosen
  * @param tag - the tab's name
  */ 
function unChooseSCTabs(tag){
	tag.className = "sc_tabs";
}

/**
  * closes shopping cart frame
  */ 
function closeSC(){
	try {
		top.topi.rows = "*,0";
		//top.bottomFrame.document.all.minimax.innerHTML = "Minimize Frame View";
		top.bottomFrame.changeImages('minimax','mini');
		minimized = null;
	}catch(e){
		minimized = null;
	}
}

/**
  * opens shopping cart frame
  */ 
function openSC(){
	top.topi.rows = "*,110";
}
/**
  * Refresh shopping cart frame
  */ 
function refreshSC(){
	top.frames.item(1).location="sc.aspx?action=refresh"
}
/**
  * Refresh shopping cart frame
  */ 
function refreshSCQueue(){
	top.frames.item(1).location="sc.aspx?action=refresh&show=queue"
}
/**
  * Navigates Top Frame
  */ 
function nvigateTop(strpage){
	top.frames.item(0).location=strpage;
}
/**
  * minimize or maximize shopping cart frame
  */ 
//function miniSC(strMax,strMin){
//	if(minimized){
//		top.topi.rows = "*,97";
//		top.bottomFrame.document.all.minimax.innerHTML = strMin;//"Minimize Frame View";
//		minimized = false;
//	}
//	else{
//		top.topi.rows = "*,18";
//		top.bottomFrame.document.all.minimax.innerHTML = strMax;//"Maximize Frame View";
//		minimized = true;
//	}
//}
function miniSC(){
	if(minimized){
		top.topi.rows = "*,110";
		top.bottomFrame.changeImages('minimax','mini');
		minimized = false;
	}
	else{
		top.topi.rows = "*,18";
		top.bottomFrame.changeImages('minimax','maxi');
		minimized = true;
	}
}
function goSecure(strUrl){
	//alert (top.location);
	top.location="https://www.indic.net/Default.aspx?action=topage&url="+strUrl;
}
function goNormal(strUrl){
	//alert (top.location);
	top.location="http://www.indic.net/Default.aspx?action=topage&url="+strUrl;
}

