function order_products_by_price(val){
	if(val!=0){
		window.location = 'http://www.gadgetline.co.il/?page=index&pr='+val 
	}
	else{
		window.location = 'http://www.gadgetline.co.il/'; 
	}
}
function order_category_products_by_price(val,c_id){
	if(val!=0){
		window.location = 'http://www.gadgetline.co.il/?page=category&c_id='+c_id+'&pr='+val;
	}
	else{
		window.location = 'http://www.gadgetline.co.il/?page=category&c_id='+c_id; 
	}
}

function change_client_address(){
	if(document.getElementById('client_address').checked){
		document.getElementById('client_address_tr').style.display = '';
	}
	else{
		document.getElementById('client_address_tr').style.display = 'none';
	}
}
function calc_general_textarea_height(obj){
	var number_of_ch = 50;
	var len = document.getElementById(obj).value.length;
	var height = len / number_of_ch;
	document.getElementById(obj).rows = height+countLines(obj);
}

function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent) {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
                curleft += obj.offsetLeft
                curtop += obj.offsetTop
        }
}
return [curleft,curtop];
}

function getElementLeft(obj)
{
	var curleft = 0;
	if(obj.offsetParent)
	while(1)
	{
		curleft += obj.offsetLeft;
		if(!obj.offsetParent)
		break;
		obj = obj.offsetParent;
	}
	else if(obj.x)
	curleft += obj.x;
	return curleft;
}

function getElementTop(obj)
{
	var curtop = 0;
	if(obj.offsetParent)
	while(1)
	{
		curtop += obj.offsetTop;
		if(!obj.offsetParent)
		break;
		obj = obj.offsetParent;
	}
	else if(obj.y)
	curtop += obj.y;
	return curtop;
}
function show_mode_details(){
	document.getElementById('tr_show_more_details').style.display = '';
}
function edit_user_password(){
	document.getElementById('password_view1').style.display='';
	document.getElementById('password_view2').style.display='';
	document.getElementById('password_view3').style.display='';
	document.getElementById('edit_password').style.display='none';
	document.getElementById('cancel_edit_password').style.display='';
}
function cancel_edit_user_password(){
	document.getElementById('password_view1').style.display='none';
	document.getElementById('password_view2').style.display='none';
	document.getElementById('password_view3').style.display='none';
	document.getElementById('edit_password').style.display='';
	document.getElementById('cancel_edit_password').style.display='none';
}
function show_albums_folder(obj){
	if(document.getElementById(obj).style.display==''){		
		document.getElementById(obj).style.display='none';
	}
	else{	
		document.getElementById(obj).style.display='';
	}
	return false;
}
function show_change_password(){
	var obj = document.getElementById('change_passowrd');
	var obj2 = document.getElementById('change_passowrd_text');

	var pass = document.getElementById('register_password');
	var conf_pass = document.getElementById('register_confirm_password');

	if(obj.style.display=='none'){
		obj.style.display = '';
		obj2.style.display = '';
	}
	else{
		obj.style.display = 'none';
		obj2.style.display = 'none';
		pass.value='';
		conf_pass.value='';
	}
}
function change_addons_sum(value){
	var addons_sum = 0;

	if(document.product_form.product_addon_1){
		for (var i=0; i < document.product_form.product_addon_1.length; i++){
			if (document.product_form.product_addon_1[i].checked){
				var rad_val = document.product_form.product_addon_1[i].value;
				var mySplitResult = rad_val.split("#%#");

				addons_sum = addons_sum+parseFloat(mySplitResult[0]);
			}
		}
	}

	if(document.product_form.product_addon_2){
		for (var i=0; i < document.product_form.product_addon_2.length; i++){
			if (document.product_form.product_addon_2[i].checked){
				var rad_val = document.product_form.product_addon_2[i].value;
				var mySplitResult = rad_val.split("#%#");

				addons_sum = addons_sum+parseFloat(mySplitResult[0]);
			}
		}
	}

	if(document.product_form.product_addon_3){
		for (var i=0; i < document.product_form.product_addon_3.length; i++){
			if (document.product_form.product_addon_3[i].checked){
				var rad_val = document.product_form.product_addon_3[i].value;
				var mySplitResult = rad_val.split("#%#");

				addons_sum = addons_sum+parseFloat(mySplitResult[0]);
			}
		}
	}

	if(document.product_form.product_addon_4){
		for (var i=0; i < document.product_form.product_addon_4.length; i++){
			if (document.product_form.product_addon_4[i].checked){
				var rad_val = document.product_form.product_addon_4[i].value;
				var mySplitResult = rad_val.split("#%#");

				addons_sum = addons_sum+parseFloat(mySplitResult[0]);
			}
		}
	}

	if(document.product_form.product_addon_5){
		for (var i=0; i < document.product_form.product_addon_5.length; i++){
			if (document.product_form.product_addon_5[i].checked){
				var rad_val = document.product_form.product_addon_5[i].value;
				var mySplitResult = rad_val.split("#%#");

				addons_sum = addons_sum+parseFloat(mySplitResult[0]);
			}
		}
	}
	document.getElementById('addons_cost').innerHTML = addons_sum+' ₪';
}
function initSlideShow() {
	var preLoad = new Array();
	for (var i = 0; i < arrBanner.length; i++) {
	preLoad[i] = new Image();
	preLoad[i].src = arrBanner[i];
	}
	var rndId = Math.floor(Math.random()*arrBanner.length);
	document.write('<img src="'+arrBanner[rndId]+'" name="SlideShow" id="SlideShow" width="206" height="140" />');
	window.setInterval('runSlideShow()', slideShowSpeed);
} // initSlideShow.
	
function runSlideShow(){
	rndId = Math.floor(Math.random()*arrBanner.length);
	if (document.all){
	document.images.SlideShow.style.filter = "blendTrans(duration=2)";
	document.images.SlideShow.style.filter = "blendTrans(duration=crossFadeDuration)";
	document.images.SlideShow.filters.blendTrans.Apply() ;
	}
	document.images.SlideShow.src = arrBanner[rndId];
	if (document.all){
	document.images.SlideShow.filters.blendTrans.Play();
	}
} // runSlideShow.

function CreateBookmarkLink() {

 title = ""; 
  // Blogger - Replace with <$BlogItemTitle$> 
  // MovableType - Replace with <$MTEntryTitle$>

 url = "";
  // Blogger - Replace with <$BlogItemPermalinkURL$> 
  // MovableType - Replace with <$MTEntryPermalink$>
  // WordPress - <?php bloginfo('url'); ?>

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
}
function checkDefault(value,obj_id){	
	if(document.getElementById(obj_id).value==''){
		document.getElementById(obj_id).value = value;
	}	
}

function clearDefault(el) {
	if (el.defaultValue==el.value) el.value = ""
}
function show_product_picture(picture_id){
	if(document.getElementById('product_big_picture_1')){
		document.getElementById('product_big_picture_1').style.display = 'none';
	}
	if(document.getElementById('product_big_picture_2')){
		document.getElementById('product_big_picture_2').style.display = 'none';
	}
	if(document.getElementById('product_big_picture_3')){
		document.getElementById('product_big_picture_3').style.display = 'none';
	}
	if(document.getElementById('product_big_picture_4')){
		document.getElementById('product_big_picture_4').style.display = 'none';
	}
	if(document.getElementById('product_big_picture_5')){
		document.getElementById('product_big_picture_5').style.display = 'none';
	}
	if(document.getElementById('product_big_picture_6')){
		document.getElementById('product_big_picture_6').style.display = 'none';
	}
	document.getElementById('product_big_picture_'+picture_id).style.display = '';
}
