function SendEMail( domain, mailbox ){
  var sLink = 'mailto:' ;
	sLink += mailbox ;
	sLink += '@' ;
	sLink += domain ;
	window.location = sLink ;	
	return false ;
}


  function findOffsetPos(obj) {
    //Находим координаты объекта относительно самого верха
  	var curleft = curtop = 0;
  	if (obj.offsetParent) {
  		do {
  			curleft += obj.offsetLeft;
  			curtop += obj.offsetTop;
  		} while (obj = obj.offsetParent);
  	}
  	return [curleft,curtop];
  }
  
  //Аналог $_GET  
  function js_get(key_str) {
  	if(window.location.search) {
  		var query = window.location.search.substr(1);
  		var pairs = query.split("&");
  		for(var i = 0; i < pairs.length; i++) {
  			var pair = pairs[i].split("=");
  			if(unescape(pair[0]) == key_str)
  				return unescape(pair[1]);
  		}
  	}
  }

  function placePopupDiv(obj, _offsetLeft, _offsetTop, _scroll){
    objName = obj;
  	obj = document.getElementById(obj);
  	if (document.documentElement)	{
  		theLeft = document.documentElement.scrollLeft;
  		theTop = document.documentElement.scrollTop;
  	}	else if (document.body)	{
  		theLeft = document.body.scrollLeft;
  		theTop = document.body.scrollTop;
  	}
  
  	theLeft += _offsetLeft;
  	theTop += _offsetTop;
  	obj.style.left = theLeft + 'px' ;
  	obj.style.top = theTop + 'px' ;
  	if (_scroll == 1){
  	 //setTimeout("placePopupDiv('"+objName+"', "+_offsetLeft+", "+_offsetTop+", 1)",100);
  	}
  }  

function openWin(_width, _height, _img, _title,_id) {
  obj_id = document.getElementById(_id)
  placePopupDiv('openwin-ramka', 0, 0, 0);
  
  _height = _height + 6;
  _width = _width + 6;
  n_height = _height + 24;
  n_width = _width + 4;
  $("#openwin-ramka").css("width", n_width+"px").css("height", n_height+"px").slideToggle(200);
  //$("#openwin-ramka-in-body").css("width", _width+"px").css("height", _height+"px").css("background", "url("+_img+")").css("background-repeat", "no-repeat").css("background-position", "center");
  
  
$("#openwin-ramka-in-body").css("width", _width+"px").css("height", _height+"px").html("<img src="+_img+" id='megaphotoforload'>");

if (!jQuery.browser.opera){
  $("#megaphotoforload").css("display", "none");
  $("#megaphotoforload").load(function(){
    $("#megaphotoforload").show();
  });
}
  
//Прячем картинку
  $("#openwin-ramka-in-body").css("cursor", "pointer").click(function(){
    $("#megaphotoforload").hide();
    $("#openwin-ramka").hide();
  })
  
  $("#openwin-ramka-in-title span.openwin-ramka-save").css("cursor", "pointer").css("color", "#fff").click(function(){
    var picname = $("#megaphotoforload").attr("src");
    document.location.href = "/e.php?action=savepic&picname="+picname;
  });

  $("#openwin-ramka-in-title span.openwin-ramka-print").css("cursor", "pointer").css("color", "#fff").click(function(){
    printdiv('openwin-ramka-in-body');
  });
  
  $("#openwin-ramka-in-title span.openwin-ramka-close").css("cursor", "pointer").css("color", "#fff").click(function(){
    $("#megaphotoforload").hide();    
    $("#openwin-ramka").hide();
  })
}



function openFlash(_width, _height, _img, _title, _id) {
  obj_id = document.getElementById(_id);
  _height = 280 + 6;
  _width = 438 + 6;
  n_height = _height + 24;
  n_width = _width + 4;  
  
  placePopupDiv('openflash-ramka', 20, 20, 1);
  $("#openflash-ramka").css("width", n_width+"px").css("height", n_height+"px").show();
  
 
  $("#openflash-ramka-in-body").css("width", _width+"px").css("height", _height+"px").html("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='438' height='280' id='panorama'><param name='movie' value='/swf/panorama.swf?name="+_img+"&pntype=0'><param name='menu' value='false'><param name='quality' value='high'><param name='bgcolor' value='#eaeef3'><embed src='/swf/panorama.swf?name="+_img+"&pntype=0' menu='false' quality='high' bgcolor='#eaeef3' width='438' height='280' name='panorama' type='application/x-shockwave-flash' pluginpage='http://www.macromedia.com/go/getflashplayer'></embed></object>");
  
//Прячем flash
  $("#openflash-ramka-in-body").css("cursor", "pointer").click(function(){
    $("#openflash-ramka").hide();
  })
  
  $("#openflash-ramka-in-title span").css("cursor", "pointer").css("color", "#fff").click(function(){
    $("#openflash-ramka").hide();
  })  
}


function openChMap(){
  _width = 956;
  _height = 900;  
  n_width = _width + 4;
  n_height = _height + 24;  
  
  placePopupDiv('openwin-ramka', 20, 20, 1);
  $("#openwin-ramka").css("width", n_width+"px").css("height", n_height+"px").show();  
  
  $("#openwin-ramka-in-body").css("width", _width+"px").css("height", _height+"px").html("<iframe src='/map_ch.php' width="+_width+" height="+_height+" frameborder=0 scrolling=no>");  
  
  
  $("#openwin-ramka-in-body").css("cursor", "pointer").click(function(){
    $("#openwin-ramka").hide();
  })
  
  $("#openwin-ramka-in-title span").css("cursor", "pointer").css("color", "#fff").click(function(){
    $("#openwin-ramka").hide();
  })      
}


function openMLDMap(){
  _width = 614;
  _height = 786;
  n_width = _width + 4;
  n_height = _height + 24;
  
  placePopupDiv('openwin-ramka', 20, 20, 1);
  $("#openwin-ramka").css("width", n_width+"px").css("height", n_height+"px").show();
  
  $("#openwin-ramka-in-body").css("width", _width+"px").css("height", _height+"px").html("<iframe src='/map_md.php' width="+_width+" height="+_height+" frameborder=0 scrolling=no>");
  
  
  $("#openwin-ramka-in-body").css("cursor", "pointer").click(function(){
    $("#openwin-ramka").hide();
  })
  
  $("#openwin-ramka-in-title span").css("cursor", "pointer").css("color", "#fff").click(function(){
    $("#openwin-ramka").hide();
  })      
}


function openWRDMap(){
  lang = js_get("lang")
  _width = 1024 + 6;
  _height = 550 + 6;  
  n_width = _width + 4;
  n_height = _height + 24;  
  
  placePopupDiv('openflash-ramka', 20, 20, 1);
  $("#openflash-ramka").css("width", n_width+"px").css("height", n_height+"px").show();
    
  $("#openflash-ramka-in-body").css("width", _width+"px").css("height", _height+"px").html("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='1024' height='550' id='panorama'><param name='movie' value='/map5_14.swf?langs="+lang+"'><param name='menu' value='false'><param name='quality' value='high'><param name='bgcolor' value='#eaeef3'><embed src='/map5_14.swf?langs="+lang+"' menu='false' quality='high' bgcolor='#eaeef3' width='1024' height='550' name='panorama' type='application/x-shockwave-flash' pluginpage='http://www.macromedia.com/go/getflashplayer'></embed></object>");
  
  
//Прячем flash
  $("#openflash-ramka-in-body").css("cursor", "pointer").click(function(){
    $("#openflash-ramka").hide();
  })
  
  $("#openflash-ramka-in-title span").css("cursor", "pointer").css("color", "#fff").click(function(){
    $("#openflash-ramka").hide();
  })    
}

function changeBannerType(){
  //Если баннер
  if (document.banner.type.value=='banner'){
    if(document.getElementById('target')) document.getElementById('target').style.display = '';
    if(document.getElementById('img')) document.getElementById('img').style.display = '';
    if(document.getElementById('link')) document.getElementById('link').style.display = '';
    if(document.getElementById('width')) document.getElementById('width').style.display = '';
    if(document.getElementById('height')) document.getElementById('height').style.display = '';
    if(document.getElementById('code')) document.getElementById('code').style.display = 'none';    
      }
  //Если флэша
  if (document.banner.type.value=='flash'){
    if(document.getElementById('target')) document.getElementById('target').style.display = 'none';
    if(document.getElementById('img')) document.getElementById('img').style.display = '';
    if(document.getElementById('link')) document.getElementById('link').style.display = 'none';
    if(document.getElementById('width')) document.getElementById('width').style.display = '';
    if(document.getElementById('height')) document.getElementById('height').style.display = '';
    if(document.getElementById('code')) document.getElementById('code').style.display = 'none'; 
    
  }
  //Если код
  if (document.banner.type.value=='code'){
    if(document.getElementById('target')) document.getElementById('target').style.display = 'none';
    if(document.getElementById('img')) document.getElementById('img').style.display = 'none';
    if(document.getElementById('link')) document.getElementById('link').style.display = 'none';
    if(document.getElementById('width')) document.getElementById('width').style.display = 'none';
    if(document.getElementById('height')) document.getElementById('height').style.display = 'none';
    if(document.getElementById('code')) document.getElementById('code').style.display = ''; 
    
  }
}


var last_price = 0;
var last_id = 0;
var configurator_id = '';



function CalcConfigurator(obj, id){
  document.getElementById('price_'+id).value=obj.value;
  document.getElementById('col_'+id).value=1;
  
  var price_total = 0;
  var configurator_id_arr = new Array();
  configurator_id_arr = configurator_id.split(",");
  for (i in configurator_id_arr){
    var ppp = 'price_'+configurator_id_arr[i];
    if (document.getElementById('price_'+configurator_id_arr[i]).value>0){
      price_total += parseFloat(document.getElementById('price_'+configurator_id_arr[i]).value) * parseFloat(document.getElementById('col_'+configurator_id_arr[i]).value)
    }
  }
  document.getElementById('price_total').value=price_total;
  
  
 // alert (document.getElementById('configurator_f').elements);
/* for (i in configurator_f.elements){
  document.write (i+"<br>")
 }*/
 

//  alert(id)
/*  document.getElementById('price_'+id).value=obj.value;
  document.getElementById('col_'+id).value=1;
  price_total = document.getElementById('price_total').value;
  if (!price_total){
    price_total = 0;
  }
  if (last_id==id || last_id==0){
//  alert (last_id)
    price_total = parseFloat(price_total) + parseFloat(obj.value) - last_price;  
    document.getElementById('price_total').value=price_total;
    last_price = obj.value;
    last_id=id;
  }else{
//  alert (last_id)  
    price_total = parseFloat(document.getElementById('price_total').value) + parseFloat(obj.value);
    document.getElementById('price_total').value=price_total;
    last_price = obj.value;
    last_id=id;
  }*/
 
}

function CalcConfiguratorCol(id){

  if (document.getElementById("price_"+id).value>0){
 document.getElementById('price_'+id).value=document.getElementById('confsel_'+id).value*document.getElementById('col_'+id).value;


  var price_total = 0;
  var configurator_id_arr = new Array();
  configurator_id_arr = configurator_id.split(",");
  for (i in configurator_id_arr){
    var ppp = 'price_'+configurator_id_arr[i];
    if (document.getElementById('price_'+configurator_id_arr[i]).value>0){
      price_total += parseFloat(document.getElementById('price_'+configurator_id_arr[i]).value)
    }
  }
  document.getElementById('price_total').value=price_total;


  }

}
