// JavaScript Document

function transfer()
{
	
}
function openwindow(name,url,width,height)
{
		
var win=window.open(url,name,"width="+width+",height="+height+",scrollbars=yes,resizeable");
win.moveTo(100,100);
win.focus();
}

function confirmDelete(text)
{
	temp = window.confirm(text);
	if (temp) 
		return true;
	else
		return false;
}

var count=0;
function create_div()
{
	count++;
	
	//hide link if more than 5
	if(count>5)
		document.getElementById("add_more_picture").style.display="none";
		
	var obj_div= document.getElementById("main_div");
	
	/* create seperate div for each input file */
	var obj_div_inner=document.createElement("div");
	obj_div_inner.setAttribute("id","div_inner"+count);
	obj_div_inner.setAttribute("name","div_inner"+count);
	obj_div.appendChild(obj_div_inner);
	
	
	/* CREATE INPUT FILE */
	var my_file=document.createElement("input");
	my_file.setAttribute("type","file");
	my_file.setAttribute("id","picture"+count);	
	my_file.setAttribute("name","picture[]");	
	
	obj_div_inner.appendChild(my_file);
	//obj_div_inner.innerHTML+='<a href="#" onclick="remove_div('+count+'); return false;"> Remove </a>';
	
	
	
	/* 	CREATE REMOVE LINK */
	if(document.all)/* 	FOR IE ONLY  */
	{ 
	
		var remove_link_div=document.getElementById("main_div_for_remove");
	var remove_link=document.createElement("a");
	remove_link.setAttribute("id","remove_link"+count);
	remove_link.setAttribute("href","javaScript:remove_div("+count+")");
	remove_link.setAttribute("value","delete");
	remove_link.setAttribute("innerHTML","Remove");
	//remove_link.setAttribute("createTextNode","Remove");
	obj_div_inner.appendChild(remove_link);	
	
		
	}else   /* FOR MOZILLA   */
	{			
		
		obj_div_inner.innerHTML+='<a href="#" onclick="remove_div('+count+'); return false;"> Remove </a>';
	}
	
	
	
	

}

function remove_div(th)
{
	var count_remove=String(th);
	var rem_file=document.getElementById("div_inner"+count_remove);
	rem_file.parentNode.removeChild(rem_file);
	
	/*reduce the runtime file browser*/
	count--;
	if(count<6)
		document.getElementById("add_more_picture").style.display="inline";
}

function show(header_id,row_id)
{
		//alert(header_id+" and "+ row_id);
	obj=document.getElementById(row_id);
	objHeader=document.getElementById(header_id);
	
	if(obj.style.display=="")
	{
	objHeader.className="menu_down";
	obj.style.display="none";
	}
	else
	{
	objHeader.className="menu_up";
	obj.style.display="";
	}	
}

function transfer()
{
	if(document.getElementById("chk_box_transfer").checked==true)
	{
		document.getElementById("txtShipFirstname").value=document.getElementById("txtFirstname").value;
		document.getElementById("txtShipLastname").value=document.getElementById("txtLastname").value;
		document.getElementById("emaShipEmail").value=document.getElementById("emaEmail").value;
		document.getElementById("txtShipPhone").value=document.getElementById("txtPhone").value;
		document.getElementById("txtShipAddress").value=document.getElementById("txtAddress").value;
		document.getElementById("txtShipCity").value=document.getElementById("txtCity").value;
		document.getElementById("txtShipState").value=document.getElementById("txtState").value;
		document.getElementById("txtShipZipcode").value=document.getElementById("txtZipcode").value;
		document.getElementById("selShipCountry").value=document.getElementById("selCountry").value;
	
	}		
	else
	{
		document.getElementById("txtShipFirstname").value='';
		document.getElementById("txtShipLastname").value='';
		document.getElementById("emaShipEmail").value='';
		document.getElementById("txtShipPhone").value='';
		document.getElementById("txtShipAddress").value='';
		document.getElementById("txtShipCity").value='';
		document.getElementById("txtShipState").value='';
		document.getElementById("txtShipZipcode").value='';
		document.getElementById("selShipCountry").value='';
	
	}
} 

function copyall(fieldname,content)
{
	
	if(document.getElementById("chk_box_transfer").checked==false)
		return false;
			
	document.getElementById(fieldname).value=content;

}
function show_largeview(picture)
{
	popup_chile=window.open("popup_product.php?picture="+picture,"popup_chile","height=500,width=650,scrollbars=yes,resizeable");
	popup_chile.moveTo(250,250);
}


function CallPrint(strid) 
{ 
 var prtContent = document.getElementById(strid); 
 var WinPrint = 
window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0'); 
<!-- WinPrint.document.write("<LINK REL='stylesheet' HREF='../app_style/cpanel_style.css' TYPE='text/css' MEDIA='print'>");-->

 WinPrint.document.write(prtContent.innerHTML); 
 WinPrint.document.close(); 
 WinPrint.focus(); 
 WinPrint.print(); 
 WinPrint.close(); 
} 


function show_thumbnail()
{
	
	if(document.getElementById("thumbnail_second").style.display=="none")
	{
		document.getElementById("thumbnail_second").style.display="inline";
		document.getElementById("thumbnail_first").style.display="none";
	}
	else
	{
		document.getElementById("thumbnail_second").style.display="none";
		document.getElementById("thumbnail_first").style.display="inline";
	}
}
