// JavaScript Document
function submit_order_form(product_number) {
	document.getElementById('order_form_n'+product_number).submit();
}


var lang_quantity, lang_id;
if (site_lang=='en') {
	lang_quantity='Quantity';
	lang_id='ID';
} else {
	lang_quantity='الكمية';
	lang_id='الرمز';
}
//Advanced Quick Order
var TotalQorderRows=0;
function new_qorder_row() {
	var row_div=document.createElement('DIV');
	row_div.className="qorder_row";
	row_div.innerHTML=lang_id+':<input type="text" name="qorders['+TotalQorderRows+'][id]" />'+
	' '+lang_quantity+':<input type="text" name="qorders['+TotalQorderRows+'][qty]" />';
	document.getElementById("adv_quickorders").appendChild(row_div);
	
	TotalQorderRows++;
}

function popup_img(img_src) {
	var img_window=window.open("view_img.php?src="+img_src,"imgs_window","height=400,width=650,location=no,menubar=no,scrollbars=no,status=no,toolbar=no");
	img_window.focus();
}

function printable_version() {
	var printable_window=window.open(window.location+'&output_type=printable', 'printable_window',"height=500,width=700,location=no,menubar=no,scrollbars=no,status=no,toolbar=no");
	printable_window.focus();
}


var SectionsAbout=new Array();
SectionsAbout['webgear']='Webgear Media are the people who programmed all of this.';
SectionsAbout['officeworld_sales']='Sales Section';
SectionsAbout['officeworld_management']='Management Section';
SectionsAbout['officeworld']='Other People';

function show_section_about(section_name)
{	
	document.getElementById('section_about').innerHTML=SectionsAbout[section_name];
}
var prev_cmnt_id=0;
function show_comment(cmnt_id, status) {
	
	//var con_elem=document.getElementById();
	var cshow_elem=document.getElementById('cmnt_'+cmnt_id+'_showimg');
	
	cshow_elem.style.display=status?'none':'';
	Effects.resizeTo('cmnt_'+cmnt_id+'_content', (status?'160' : '0')+'px', '');
	if(prev_cmnt_id && status) {
		show_comment(prev_cmnt_id, false);
	}
	prev_cmnt_id=cmnt_id;
}




/*
 *		Resize
 */
Effects={}; 
//comon things:
Effects.Common={}
Effects.Common.parseLength=function (lengthStr) {
	var lenVal=parseInt(lengthStr);
	var usedUnit=lengthStr.substr((lenVal+"").length);
	
	var ToReturn=new Object();
	ToReturn.lenVal=lenVal;
	ToReturn.usedUnit=usedUnit;
	return ToReturn;
}
Effects.resizeTo=function (elemId, targetHeight, targetWidth) {
	
	var elem=document.getElementById(elemId);
	var currentWidth =parseInt(elem.style.width);
	var currentHeight=parseInt(elem.style.height);
	
	//shared things
	var steps=5;
	var Key=elem.Key=Math.random();
	var stepDelay=67;
	//width vars
	var widthInfo=Effects.Common.parseLength(targetWidth);
	var wanted_width=widthInfo.lenVal;
	var width_distance=wanted_width-currentWidth;
	var unitToUse_Width=widthInfo.usedUnit;
	var stepSize_Width=width_distance/steps;
	//height vars
	var heightInfo=Effects.Common.parseLength(targetHeight);
	var wanted_height=heightInfo.lenVal;
	var height_distance=wanted_height-currentHeight;
	var unitToUse_Height=heightInfo.usedUnit;
	var stepSize_Height=height_distance/steps;
	
	for(var i=0; i<steps; i++) {
		var call_str="Effects.setSizeByKey('"+elemId+"','"+
			(currentHeight+(stepSize_Height*i))+unitToUse_Height+"', '"+
			(currentWidth+(stepSize_Width*i))+unitToUse_Width+"', "+Key
			+")";
		
		setTimeout(call_str, stepDelay*i);
	}
	var call_str="Effects.setSizeByKey('"+elemId+"','"+
			(targetHeight)+"', '"+
			(targetWidth)+"', "+Key
			+")";
	setTimeout(call_str, stepDelay*steps);
}

Effects.setSize=function (elemId, height, width) {
	var elem=document.getElementById(elemId);
	elem.style.width=width;
	elem.style.height=height;
}

Effects.setSizeByKey= function (elemId, height, width, Key) {
	var elem=document.getElementById(elemId);
	if (elem.Key==Key) {
		Effects.setSize(elemId, height, width);
	}
}