var sel_drop_down;
var custom_ajax_2=0;
var horizontal_offset="9px"; //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0"; //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all;
var ns6=document.getElementById&&!document.all;

function serealize_request(val){
	
	val=val.replace(/\//g,"\\");
	val=val.replace(/-/g,"_");
	return val;
}
function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1;
	if (whichedge=="rightedge"){
		var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40;
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
		edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset);
	}
	else{
		var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18;
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight;
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
		edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight;
	}
	return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
				if ((ie||ns6) && document.getElementById("hintbox")){
						dropmenuobj=document.getElementById("hintbox");
						dropmenuobj.innerHTML=menucontents;
						dropmenuobj.style.left=dropmenuobj.style.top=-500;
						if (tipwidth!=""){
							dropmenuobj.widthobj=dropmenuobj.style;
							dropmenuobj.widthobj.width=tipwidth;
						}
						dropmenuobj.x=getposOffset(obj, "left");
						dropmenuobj.y=getposOffset(obj, "top");
						dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px";
						dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px";
						dropmenuobj.style.visibility="visible";
						obj.onmouseout=hidetip;
				}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden";
dropmenuobj.style.left="-500px";
}

function createhintbox(){
	var divblock=document.createElement("div");
	divblock.setAttribute("id", "hintbox");
	document.body.appendChild(divblock);
}

if (window.addEventListener) window.addEventListener("load", createhintbox, false);
else if (window.attachEvent) window.attachEvent("onload", createhintbox);
else if (document.getElementById) window.onload=createhintbox;

function NewWin(objpath,w,h)
{
	h=150;
	window.open(objpath,"",'scrollbars=1, resizable=1, width=' +w+ ',height=' +h+ ',left=500,top=400');
}	
function li_hover(elem)
{
	elem.style.background='#F1EFEC';
}
function li_out(elem)
{
	elem.style.background='#FAFAFA';
}


//ot credit-bg

function sel_region(id_region)
{
	loadXMLContentRead("includes/load_city.php?id_region="+id_region);
}

function loadXMLContentRead(url) {
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest;
        req.onreadystatechange = processReqRead;
        req.open("GET", url, true);
        req.send(null);
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqRead;
            req.open("GET", url, true);
            req.send(null);
        }
    }
}

function processReqRead() {
	 if (req.readyState == 4) {
        if (req.status == 200) {
		 if(req.responseText !="")
		 {
		 	content=req.responseText;
			if(content!=""){
			document.getElementById('property_city').innerHTML="";
			arr_cities=content.split("<>");
			for(i=0;i<arr_cities.length-1;i++)
			{
				cities=arr_cities[i];
				det_cities=cities.split("->");
				var option=document.createElement('option');
				option.setAttribute('value',det_cities[0]);
				var currenttext = document.createTextNode(det_cities[1]);
				option.appendChild(currenttext);
				document.getElementById('property_city').appendChild(option);
			}
		}
				
				
			
			
		  }
		}
	}
}



function choise_action(form_action)
{
	form_target="";
	form_action1="";
	document.calculator.target=form_target;
	if(form_action1!="") document.calculator.action=form_action1;
	
	
}





function isValidPhone(str) {
//alert(str);
	str=str.replace(/ /g,'');
	if (str.length < 6) { return false; }
	if (/[^0-9-]/.test(str)) { return false; }

	
	return true;
}

function isValidYear(str) {
	str=str.replace(/ /g,'');
	if (str.length != 4 ) { return false; }
	if (/[^0-9-]/.test(str)) { return false; }
	if(str<1900){ return false; }
	if(str>2008){ return false; }
	return true;
}
function ValidName(strName) {
	if (/[^A-Za-z -'абвгдежзийклмнопрстуфхцчшщьъюяАБВГДЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЪЮЯ']/.test(strName)) { return false; }
	return true;
}

function ValidStreetAddress(strAddress) {
	if (strAddress.length < 3) { return false; }
	return true;
}


//za 4islo
function js_check_value_numeric(val,val_min,val_max){
	var objRegExp  =/(^-?\d\d*$)/;
	if(val>=val_min && val<=val_max)return objRegExp.test(val);
	else return false;
}

function validateInteger( strValue ) {
  var objRegExp  = /(^-?\d\d*$)/;

  //check for integer characters
  return objRegExp.test(strValue);
}
function js_check_value_char(val,val_min,val_max){
	if(val.length>=val_min && val.length<=val_max)return true;
	else return false;
}
function js_check_value_checkbox(val,val_min,val_max){
	if(val=='on')return true;
	else return false;
}
function js_check_value_tc(val,val_min,val_max){
	if(val=='on')return true;
	else return false;
}
function change_checkbox(element)
{
	var el=element;
	if(el.checked) el.value='on';
	else el.value='false';
}
function js_check_value_mail(val,val_min,val_max){
	var objRegExp  =/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
	return objRegExp.test(val);
}
function validateEmail( strValue) {
var objRegExp  =/(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;

  //check for valid email
  return objRegExp.test(strValue);
}

function send_form()
{
	//window.alert("test"+document.getElementById("nav").value);
	
		if(document.getElementById("nav").value==1)
		{
			if(js_check_form_field_value()==true)return false;
			else return true;
		}else return true;
}


function send_search_form(){
	url=url_mine_site;
	delim="";
	if(document.getElementById('hscs').checked==true){
		if(document.getElementById('city_id').value && document.getElementById('city_id').value!=0){
			url +=document.getElementById('city_id').value;
				delim="_";
		}
		if(document.getElementById('region_id').value){
			url +=delim+document.getElementById('region_id').value+"-обяви";
				delim="-";
		}
		if(document.getElementById('sub_category_id').value && document.getElementById('sub_category_id').value!=0) {
			url +=delim+document.getElementById('sub_category_id').value;
			delim="_";
		}
		if(document.getElementById('category').value) {
			url +=delim+document.getElementById('category').value;
			delim="-";
		}
		for (var i=0; i<document.custom_search_form.offer_type.length; i++) {
			if (document.custom_search_form.offer_type[i].checked)  {
				url +=delim+"обява-"+document.custom_search_form.offer_type[i].value;
				delim="-";
			} 
		}
	}
	if(document.getElementById('search').value)url +=delim+"kwd-"+document.getElementById('search').value;
	url+=".html";
	window.location=url;
	return false;
}





function loadXMLContentRead1(url) {
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest;
        req.onreadystatechange = processReqRead1;
        req.open("GET", url, true);
        req.send(null);
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqRead1;
            req.open("GET", url, true);
            req.send(null);
        }
    }
}

function processReqRead1() {
	 if (req.readyState == 4) {
        if (req.status == 200) {
		 	if(req.responseText !="")
		 	{
				content=req.responseText;
				//alert(document.getElementById('kod_calc'));
				if(content!=""){
				content=content.replace(/\[/g,"&lt;");
				content=content.replace(/\]/g,"&gt;");
					document.getElementById('gen_kod_frame').innerHTML=content;
							
				}
			}
		}
	}
}

function ch_calcs(){
id_calc=document.getElementById('calculator_id').value;
url="../calculators/generate_calc_kod.php?calculator_id="+id_calc;
loadXMLContentRead1(url);
return false;
}



//izbiraiki region ti se listvat vsichki gradove v tozi region
function sel_city(i,g){	
	var id_region=document.getElementById(g).value;
	
	url=url_mine_site+"/includes/get_cities.php?id_region="+id_region;
	//alert(url);
	t_select=document.getElementById(i);
	t_select.innerHTML='';	
	loadXMLContentDropDown(url);
	//alert(id_region);
	if(id_region!=0 && id_region!="Цялата-страна"){
		document.getElementById('hide_city_id').style.display='';
		
	}else {
		document.getElementById('hide_city_id').style.display='none';
	}
}

function sel_sub_category(i,g){	
	var id_region=document.getElementById(g).value;
	
	url=url_mine_site+"includes/get_sub_category.php?parent_id="+id_region;
	t_select=document.getElementById(i);
	t_select.innerHTML='';	
	loadXMLContentDropDown(url);
	switch (id_region){
	case "2": 
	case "4":
	case "5":
	case "7":
	case "9":
	case "10":
	case "18":
	case "24":
	case "Автомобили":
	case "Имоти":
	case "Имоти-под-наем":
	case "Работа":
	case "Образование":
	case "Услуги":
	case "Здраве-и-красота":
	case "Животни-и-растения":
		document.getElementById('hide_sub_category_id').style.display='';
	break;
		default :
			document.getElementById('hide_sub_category_id').style.display='none';
		break;
	}
}

function loadXMLContentDropDown(url){

    if (window.XMLHttpRequest) {

        req = new XMLHttpRequest;

        req.onreadystatechange = processReqDD;

        req.open("GET", url, true);

        req.send(null);

    } else if (window.ActiveXObject) {

        isIE = true;

        req = new ActiveXObject("Microsoft.XMLHTTP");

        if (req) {

            req.onreadystatechange = processReqDD;

            req.open("GET", url, true);

            req.send(null);

        }

    }

}

function processReqDD() {
	 if (req.readyState == 4) {
        if (req.status == 200) {
		 	if(req.responseText !="")
		 	{
		 		msg=req.responseText;
				if (typeof DOMParser == "undefined") {
   					DOMParser = function () {}
   					DOMParser.prototype.parseFromString = function (str, contentType) {
      				if (typeof ActiveXObject != "undefined") {
				         var d = new ActiveXObject("MSXML.DomDocument");
				         d.loadXML(str);
				         return d;
				      } else if (typeof XMLHttpRequest != "undefined") {
				         	var req = new XMLHttpRequest;
				        	req.open("GET", "data:" + (contentType || "application/xml") + 	";charset=windows-1251," + encodeURIComponent(str), false);
				        	if (req.overrideMimeType) {
				           		req.overrideMimeType(contentType);
				        	}
							req.send(null);
				        	return req.responseXML;
				      	}
   			  		}
				}
				var xmlobject = (new DOMParser()).parseFromString(msg, "text/xml");
				var root = xmlobject.getElementsByTagName('nmsg')[0];
				var items = root.getElementsByTagName("item");
				for (var i = 0 ; i < items.length ; i++) {
					var item = items[i];
					var type_elem = item.getAttribute("elem");					
					switch(type_elem){
						case 'option' :
							var e_option=document.createElement('option');
							try{
								var currenttext = document.createTextNode(item.firstChild.nodeValue);
								e_option.appendChild(currenttext); 
							}catch(err){
								var currenttext = document.createTextNode("-");
								e_option.appendChild(currenttext); 
							}
							add_elemnt(e_option,item);
							if(sel_drop_down == e_option.value)e_option.selected=true;
							t_select.appendChild(e_option); 
						break;
					}
				}
				if(custom_ajax_2==1){
					sel_city('city_id','region_id');
					custom_ajax_2=0;
				}
			}
		}
	}
}

function add_elemnt(element,xmlelem){
	var elem=element;
	var attribute = xmlelem.getAttribute("id");
	if(attribute != '' && attribute != null)elem.setAttribute('id',attribute);
	var attribute = xmlelem.getAttribute("width");
	if(attribute != '' && attribute != null)elem.setAttribute('width',attribute);
	var attribute = xmlelem.getAttribute("colspan");
	if(attribute != '' && attribute != null)elem.setAttribute('colspan',attribute);
	var attribute = xmlelem.getAttribute("bg");
	if(attribute != '' && attribute != null)elem.style.background=attribute;
	var attribute = xmlelem.getAttribute("border");
	if(attribute != '' && attribute != null)elem.style.border=attribute;
	var attribute = xmlelem.getAttribute("color");
	if(attribute != '' && attribute != null)elem.style.color=attribute;
	var attribute = xmlelem.getAttribute("value");
	if(attribute != '' && attribute != null)elem.setAttribute('value',attribute);
	var attribute = xmlelem.getAttribute("js");
	if(attribute!='' && attribute!=null){
		arr_js=attribute.split("#");
		for(i=0;i<arr_js.length;i++){
			str_event=arr_js[i].split("=");
			the_event=str_event[0];
			the_function=str_event[1];
			addEvent(elem, the_event, eval(the_function), false);

		}

	}

}
function addEvent(obj, evType, fn, useCapture){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, useCapture);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		alert("Handler could not be attached");
	}
 
}
function change_cities(){
	var region_id='region';
	var city_id='city';
	new_region=document.getElementById(region_id).value;
	url="http://www.getins.bg/distribute/changeRegion/region_id-"+new_region+"/elem_city-"+city_id+".js";
	var head = document.getElementsByTagName("head").item(0);
	var script = document.createElement("script");
	script.setAttribute("type", "text/javascript");
	script.setAttribute("src", url);
	head.appendChild(script);
}
function change_cities_go(){
	var region_id='inicial_regions';
	var city_id='city';
	new_region=document.getElementById(region_id).value;
	url="http://www.getins.bg/distribute/changeRegionGo/region_id-"+new_region+"/elem_city-"+city_id+".js";
	var head = document.getElementsByTagName("head").item(0);
	var script = document.createElement("script");
	script.setAttribute("type", "text/javascript");
	script.setAttribute("src", url);
	head.appendChild(script);
	
}
function change_city(v1,v2){
	var region_id=v1;
	var city_id=v2;
	new_region=document.getElementById(region_id).value;
	url="http://www.getins.bg/distribute/changeRegionGo/region_id-"+new_region+"/elem_city-"+city_id+".js";
	var head = document.getElementsByTagName("head").item(0);
	var script = document.createElement("script");
	script.setAttribute("type", "text/javascript");
	script.setAttribute("src", url);
	head.appendChild(script);
}
function find_selected_option(el,elvalue){
	var elem=document.getElementById(el);
	opts=elem.options;
	for(i=0;i<opts.length;i++){
		if(opts[i].value==elvalue)opts[i].selected=true;
		else opts[i].selected=false;
	}
}
function add_cities(JSONData){
	if (JSONData != null){
		id_city=JSONData.ResultSet.elem_city;
		document.getElementById(id_city).innerHTML='';
		cnt=1*JSONData.ResultSet.totalResultsReturned;
		for (i=0; i<cnt; i++){
			var  opt= document.createElement("option");	
			opt.setAttribute('value',JSONData.ResultSet.Result[i].value);
			var t=document.createTextNode(JSONData.ResultSet.Result[i].pr_value);
			opt.appendChild(t);
			document.getElementById(id_city).appendChild(opt);
		}
	}
}
function choise_copmany_price(e) {
	if (!e) var e = window.event;
	try{
		var el=e.srcElement;
		idelem=el.id;
		d=idelem.split("_");
	}catch(err){
		idelem=this.id;
		d=idelem.split("_");
	}
	document.getElementById("price_id").value=d[1];
	document.getElementById("numb_vnoski").value=d[2];
	url='http://www.getins.bg/distribute/contactDetails/price_id-'+d[1]+'/numb_vnoski-'+d[2]+'.js';
	var head = document.getElementsByTagName("head").item(0);
	var script = document.createElement("script");
	script.setAttribute("type", "text/javascript");
	script.setAttribute("src", "http://www.getins.bg/jsform/2.js");
	head.appendChild(script);
	var script = document.createElement("script");
	script.setAttribute("type", "text/javascript");
	script.setAttribute("src", url);
	head.appendChild(script);
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}
function choise_copmany_price_kasko(e) {
	if (!e) var e = window.event;
	try{
		var el=e.srcElement;
		idelem=el.id;
		d=idelem.split("_");
	}catch(err){
		idelem=this.id;
		d=idelem.split("_");
	}
	document.getElementById("price_id").value=d[1];
	document.getElementById("numb_vnoski").value=d[2];
	url='http://www.getins.bg/distribute/contactDetailsKasko/price_id-'+d[1]+'/numb_vnoski-'+d[2]+'.js';
	var head = document.getElementsByTagName("head").item(0);
	var script = document.createElement("script");
	script.setAttribute("type", "text/javascript");
	script.setAttribute("src", "http://www.getins.bg/jsform/2.js");
	head.appendChild(script);
	var script = document.createElement("script");
	script.setAttribute("type", "text/javascript");
	script.setAttribute("src", url);
	head.appendChild(script);
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}

function get_go_calc()
{
	var check_form=false;
	if(document.getElementById("nav").value==1)
		{			
			if(js_check_form_1_field_value()==true)check_form= false;
			else {
				check_form= true;
				switch (document.getElementById('car_type_id').value){
				case '1'://leki konski_sili
					if(document.getElementById('kubatura').value=='0'){
						check_form= false;
						alert("Моля изберете кубатура на автомобила");
					}
					//alert(document.getElementById('tovaronosimost').value);
				break;
				case '2': //tovaren
					if(document.getElementById('tovaronosimost').value=='0'){
						check_form= false;
						alert("Моля изберете товароносимост");
					}
				break;
				case '3'://motoped
					if(document.getElementById('kubatura_mtp').value=='0'){
						check_form= false;
						alert("Моля изберете кубатура");
					}
				break;
				case '4'://motociklet
					if(document.getElementById('kubatura_mtp').value=='0'){
						check_form= false;
						alert("Моля изберете кубатура");
					}
				break;
				case '7'://tovarno remarke
					if(document.getElementById('tovaronosimost_rem').value=='0'){
						check_form= false;
						alert("Моля изберете товароносимост");
					}
				break;
				case '8'://vleka4
				break;
				case '9'://avtobus
					if(document.getElementById('mesta_bus').value=='0'){
						check_form= false;
						alert("Моля изберете брой места");
					}
				break;
				case '17'://traktor					
				break;
				}

				
			}
		}else check_form= true;
	if(check_form){
		//vsi4ko e to4no
		//alert("test");
		document.getElementById("central_part").style.display="none";
		//document.getElementById("transparent").style.display="";
		//document.getElementById("transparent").style.height="100%";
		document.getElementById("view_price_cont").style.display="";
		document.getElementById("view_price_container").style.display='';
		document.getElementById("view_price_container").innerHTML="Зареждане на резултатите ...";
		document.getElementById("contacts_details_form").style.display='none';
		
		document.getElementById("table_actualni_ceni").style.display='';
		//document.getElementById("table_cont_details").style.display='none';
		//document.getElementById("view_price_head").style.width='958px';
		//document.getElementById("fields_holder").style.display='none';
		JSRequest=getJsonRequest1();
		url='http://www.getins.bg/distribute/viewPriceGONew';
		url +=JSRequest+"/ct-"+currentTime+"/agent_id-"+document.getElementById('agent_id').value+".js";
//alert(url);		
		var head = document.getElementsByTagName("head").item(0);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", url);
		head.appendChild(script);
		return false;
	}else return check_form;
}


function get_professional_calc()
{
	var check_form=false;
	if(document.getElementById("nav").value==1)
		{
			if(js_check_form_70_field_value()==true)check_form= false;
			else check_form= true;
		}else check_form= true;
	if(check_form){
		//vsi4ko e to4no
		JSRequest=getJsonRequest70();
		url='http://www.getins.bg/distribute/professional';
		url +=JSRequest+"/agent_id-"+document.getElementById('agent_id').value+".js";
//alert(url);		
		var head = document.getElementsByTagName("head").item(0);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", url);
		head.appendChild(script);
		return false;
	}else return check_form;
}


function professional(JSONData){
	if (JSONData != null) tank_page(JSONData)
}

function get_accident_calc()
{
	var check_form=false;
	if(document.getElementById("nav").value==1)
		{
			if(js_check_form_60_field_value()==true)check_form= false;
			else check_form= true;
		}else check_form= true;
	if(check_form){
		//vsi4ko e to4no
		JSRequest=getJsonRequest60();
		url='http://www.getins.bg/distribute/viewAccident';
		url +=JSRequest+"/agent_id-"+document.getElementById('agent_id').value+".js";
//alert(url);		
		var head = document.getElementsByTagName("head").item(0);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", url);
		head.appendChild(script);
		return false;
	}else return check_form;
}


function viewAccident(JSONData){
	if (JSONData != null) tank_page(JSONData)
}

function get_healt_calc()
{
	var check_form=false;
	if(document.getElementById("nav").value==1)
		{
			if(js_check_form_50_field_value()==true)check_form= false;
			else check_form= true;
		}else check_form= true;
	if(check_form){
		//vsi4ko e to4no
		JSRequest=getJsonRequest50();
		url='http://www.getins.bg/distribute/viewHealt';
		url +=JSRequest+"/agent_id-"+document.getElementById('agent_id').value+".js";
//alert(url);		
		var head = document.getElementsByTagName("head").item(0);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", url);
		head.appendChild(script);
		return false;
	}else return check_form;
}


function viewHealt(JSONData){
	if (JSONData != null) tank_page(JSONData)
}

function get_liveins_calc()
{
	var check_form=false;
	if(document.getElementById("nav").value==1)
		{
			if(js_check_form_40_field_value()==true)check_form= false;
			else check_form= true;
		}else check_form= true;
	if(check_form){
		//vsi4ko e to4no
		JSRequest=getJsonRequest40();
		url='http://www.getins.bg/distribute/viewLive';
		url +=JSRequest+"/agent_id-"+document.getElementById('agent_id').value+".js";
//alert(url);		
		var head = document.getElementsByTagName("head").item(0);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", url);
		head.appendChild(script);
		return false;
	}else return check_form;
}


function viewLive(JSONData){
	if (JSONData != null) tank_page(JSONData)
}

function get_imot_calc()
{
	var check_form=false;
	if(document.getElementById("nav").value==1)
		{
			if(js_check_form_20_field_value()==true)check_form= false;
			else check_form= true;
		}else check_form= true;
	if(check_form){
		//vsi4ko e to4no
		JSRequest=getJsonRequest20();
		url='http://www.getins.bg/distribute/viewImot';
		url +=JSRequest+"/agent_id-"+document.getElementById('agent_id').value+".js";
//alert(url);		
		var head = document.getElementsByTagName("head").item(0);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", url);
		head.appendChild(script);
		return false;
	}else return check_form;
}


function viewImot(JSONData){
	if (JSONData != null) tank_page(JSONData)
}

function get_turist_calc()
{
	var check_form=false;
	if(document.getElementById("nav").value==1)
		{
			if(js_check_form_30_field_value()==true)check_form= false;
			else check_form= true;
		}else check_form= true;
	if(check_form){
		//vsi4ko e to4no
		JSRequest=getJsonRequest30();
		url='http://www.getins.bg/distribute/viewTurist';
		url +=JSRequest+"/agent_id-"+document.getElementById('agent_id').value+".js";
//alert(url);		
		var head = document.getElementsByTagName("head").item(0);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", url);
		head.appendChild(script);
		return false;
	}else return check_form;
}


function viewTurist(JSONData){
	if (JSONData != null) tank_page(JSONData)
}


function tank_page(JSONData){
	if (JSONData != null){
	
		document.getElementById('getins_title_popup').innerHTML='Приета заявка';
		document.getElementById("view_price_container").style.display='none';
		document.getElementById("table_actualni_ceni").style.display='none';
		document.getElementById("contacts_details_form").style.display='';
		//document.getElementById("table_cont_details").style.display='';
		//document.getElementById("view_price_head").style.width='400px';
		document.getElementById('contacts_details_form').innerHTML='';
		var p_thank=document.createElement("p");
		var thank_txt=document.createTextNode(JSONData.ResultSet.thank_txt);
		p_thank.appendChild(thank_txt);	
		document.getElementById("contacts_details_form").appendChild(p_thank);	
		cnt=1*JSONData.ResultSet.totalResultsReturned;
		var table_form=document.createElement("table");
		var table_head=document.createElement("thead");
		table_form.appendChild(table_head);	
		var table_body=document.createElement("tbody");
		for (i=0; i<cnt; i++){
			if(JSONData.ResultSet.Result[i].field_value!='' && JSONData.ResultSet.Result[i].field_value!='0'){
				var  tr= document.createElement("tr");
				var td= document.createElement("td");
				var abrv=document.createTextNode(JSONData.ResultSet.Result[i].field_name);			
				td.appendChild(abrv);			
				tr.appendChild(td);
				var td= document.createElement("td");
				var abrv=document.createTextNode(JSONData.ResultSet.Result[i].field_value);
				td.appendChild(abrv);			
				tr.appendChild(td);
				table_body.appendChild(tr);
			}
		}	
		table_form.appendChild(table_body);
		document.getElementById("contacts_details_form").appendChild(table_form);
		document.getElementById("transparent").style.display="";
		//document.getElementById("transparent").style.height="100%";
		document.getElementById("view_price_cont").style.display="";
		document.getElementById("view_price_container").style.display='';
		document.getElementById("fields_holder").style.display='none';
	 }
}
function get_kasko_calc()
{
	var check_form=false;
	if(document.getElementById("nav").value==1)
		{
			if(js_check_form_10_field_value()==true)check_form= false;
			else check_form= true;
		}else check_form= true;
	if(check_form){
		//vsi4ko e to4no
		JSRequest=getJsonRequest10();
		url='http://www.getins.bg/distribute/viewPriceKasko';
		url +=JSRequest+"/agent_id-"+document.getElementById('agent_id').value+".js";
//alert(url);		
		var head = document.getElementsByTagName("head").item(0);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", url);
		head.appendChild(script);
		return false;
	}else return check_form;
}

function send_contact_details(e){
	if (!e) var e = window.event;
	var check_form=false;
	try{
			document.getElementById('buttonSendContactForm').style.display='none';
			document.getElementById('buttonProcesingContactForm').style.display='';
		}catch(err){ }
	if(js_check_form_2_field_value()==true)check_form= false;
	else check_form= true;	
	if(check_form){
			//vsi4ko e to4no
		JSRequest=getJsonRequest2();
		url='http://www.getins.bg/distribute/wonerDetails';
		document.getElementById('buttonSendContactForm').style.display='none';
		document.getElementById('buttonProcesingContactForm').style.display='';
		//document.getElementById('contacts_details_form').innerHTML="Обработка на даннинте.<br>Моля Изчакайте";
		var head = document.getElementsByTagName("head").item(0);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", "http://www.getins.bg/jsform/3.js");
		head.appendChild(script);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		//alert(url+JSRequest+'.js');
		script.setAttribute("src", url+JSRequest+'.js');
		head.appendChild(script);
		//alert(url+JSRequest+'.js');
		e.cancelBubble = true;
		return false;	
	}else {
		try{
			document.getElementById('buttonSendContactForm').style.display='';
			document.getElementById('buttonProcesingContactForm').style.display='none';
		}catch(err){}
		return check_form;
	}
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}

function send_contact_details_kasko(e){
	if (!e) var e = window.event;
	var check_form=false;
	try{
			document.getElementById('buttonSend').style.display='none';
			document.getElementById('buttonProcesing').style.display='';
		}catch(err){}
	if(js_check_form_2_field_value()==true)check_form= false;
	else check_form= true;	
	if(check_form){
			//vsi4ko e to4no
		JSRequest=getJsonRequest2();
		url='http://www.getins.bg/distribute/registerKasko';
		document.getElementById('contacts_details_form').innerHTML="Обработка на даннинте.<br>Моля Изчакайте";
		var head = document.getElementsByTagName("head").item(0);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", "http://www.getins.bg/jsform/3.js");
		head.appendChild(script);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", url+JSRequest+'.js');
		head.appendChild(script);
		//alert(url+JSRequest);
		e.cancelBubble = true;
		return false;	
	}else {
		try{
			document.getElementById('buttonSend').style.display='';
			document.getElementById('buttonProcesing').style.display='none';
		}catch(err){}
		return check_form;
	}
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}

function send_owner_details(e){
	if (!e) var e = window.event;
	var check_form=false;
	try{
			document.getElementById('buttonSendowner_details_form').style.display='none';
			document.getElementById('buttonProcesingowner_details_form').style.display='';
		}catch(err){}
	if(js_check_form_3_field_value()==true)check_form= false;
	else check_form= true;	
	if(check_form){
			//vsi4ko e to4no
		JSRequest=getJsonRequest3();
		url='http://www.getins.bg/distribute/driverDetails';
		document.getElementById('buttonSendowner_details_form').style.display='none';
		document.getElementById('buttonProcesingowner_details_form').style.display='';
		var head = document.getElementsByTagName("head").item(0);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", "http://www.getins.bg/jsform/4.js");
		head.appendChild(script);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", url+JSRequest+'.js');
		head.appendChild(script);
		//alert(url+JSRequest);
		e.cancelBubble = true;
		return false;	
	}else {
		try{
			document.getElementById('buttonSend').style.display='';
			document.getElementById('buttonProcesing').style.display='none';
		}catch(err){}
		return check_form;
	}
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}

function send_driver_details(e){
	if (!e) var e = window.event;
	var check_form=false;
	try{
			document.getElementById('buttonSenddriver_details_form').style.display='none';
			document.getElementById('buttonProcesingdriver_details_form').style.display='';
		}catch(err){}
	if(js_check_form_4_field_value()==true)check_form= false;
	else check_form= true;	
	if(check_form){
			//vsi4ko e to4no
		JSRequest=getJsonRequest4();
		url='http://www.getins.bg/distribute/mpsDetails';
		document.getElementById('buttonSenddriver_details_form').style.display='none';
		document.getElementById('buttonProcesingdriver_details_form').style.display='';
		var head = document.getElementsByTagName("head").item(0);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", "http://www.getins.bg/jsform/5.js");
		head.appendChild(script);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", url+JSRequest+'.js');
		head.appendChild(script);
		//alert(url+JSRequest);
		e.cancelBubble = true;
		return false;	
	}else {
		try{
			document.getElementById('buttonSend').style.display='';
			document.getElementById('buttonProcesing').style.display='none';
		}catch(err){}
		return check_form;
	}
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}

function send_mps_details(e){
	if (!e) var e = window.event;
	var check_form=false;
	try{
			document.getElementById('buttonSendmps_details_form').style.display='none';
			document.getElementById('buttonProcesingmps_details_form').style.display='';
		}catch(err){}
	if(js_check_form_5_field_value()==true)check_form= false;
	else check_form= true;	
	if(check_form){
			//vsi4ko e to4no
		JSRequest=getJsonRequest5();
		url='http://www.getins.bg/distribute/registerGo';
		document.getElementById('buttonSendmps_details_form').style.display='none';
		document.getElementById('buttonProcesingmps_details_form').style.display='';
		var head = document.getElementsByTagName("head").item(0);
		var script = document.createElement("script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", url+JSRequest+'.js');
		head.appendChild(script);
		//alert(url+JSRequest);
		e.cancelBubble = true;
		return false;	
	}else {
		try{
			document.getElementById('buttonSend').style.display='';
			document.getElementById('buttonProcesing').style.display='none';
		}catch(err){}
		return check_form;
	}
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}

function distribute_listing(param){
	url='http://www.getins.bg/distribute/viewPrice';
	url +=param+".js";	
	var head = document.getElementsByTagName("head").item(0);
    var script = document.createElement("script");
    script.setAttribute("type", "text/javascript");
	script.setAttribute("src", url);
	head.appendChild(script);
	return false;
}


var th_1=new Array('Еднократна вноска','Две вноски','Три вноски','Четири вноски');
var th_colspan_1=new Array('1','3','3','3');
var th_class_1=new Array('vn1','vn2','vn3','vn4');
var th_2=new Array('I Вноска','II Вноскa','Общо');
var th_3=new Array('I Вноска','II Вноскa','III Вноскa','Общо');
var th_4=new Array('I Вноска','II Вноскa','III Вноскa','IV Вноскa','Общо');
var th_class_2=new Array('vn1','vn2','vn2','vn2','vn3','vn3','vn3','vn4','vn4','vn4');

function contactDetails(JSONData){
	 if (JSONData != null){
		//document.getElementById('getins_title_popup').innerHTML='Данни за Контакт';
		listFormDetails1(JSONData);		
	 }
}
function contactDetailsNew(JSONData){
	 if (JSONData != null){
		//document.getElementById('getins_title_popup').innerHTML='Данни за Контакт';
		listFormDetails1(JSONData);		
	 }
}

function listFormDetails1(JSONData){
		document.getElementById("view_price_container").style.display='none';
		document.getElementById("view_contact_details").style.display='';
		document.getElementById("contacts_details_form").style.display="";
		document.getElementById('contacts_details_form').style.width='760px';
		
		document.getElementById('VP').innerHTML="<b>Компания "+JSONData.ResultSet.CompanyName+"</b><br>";
		if(JSONData.ResultSet.NumbVnoski==1){
			document.getElementById('VP').innerHTML +="Еднократна Вноска <br>";
			document.getElementById('VP').innerHTML +="Цена: <b>"+JSONData.ResultSet.price_1_1 +"лв.</b><br>";
		}
		if(JSONData.ResultSet.NumbVnoski==2){
			document.getElementById('VP').innerHTML +="Две Вноски <br>";
			document.getElementById('VP').innerHTML +="Първа Вноска: "+JSONData.ResultSet.price_2_1 +"лв.<br>";
			document.getElementById('VP').innerHTML +="Втора Вноска: "+JSONData.ResultSet.price_2_2 +"лв.<br>";
			document.getElementById('VP').innerHTML +="Крайна Цена: <b>"+JSONData.ResultSet.price_2 +"лв.</b><br>";
		}
		if(JSONData.ResultSet.NumbVnoski==3){
			document.getElementById('VP').innerHTML +="Три Вноски <br>";
			document.getElementById('VP').innerHTML +="Първа Вноска: "+JSONData.ResultSet.price_3_1 +"лв.<br>";
			document.getElementById('VP').innerHTML +="Втора Вноска: "+JSONData.ResultSet.price_3_2 +"лв.<br>";
			document.getElementById('VP').innerHTML +="Трета Вноска: "+JSONData.ResultSet.price_3_2 +"лв.<br>";
			document.getElementById('VP').innerHTML +="КрайнаЦена: <b>"+JSONData.ResultSet.price_3 +"лв.</b><br>";
		}
		if(JSONData.ResultSet.NumbVnoski==4){
			document.getElementById('VP').innerHTML +="Четири Вноски <br>";
			document.getElementById('VP').innerHTML +="Първа Вноска: "+JSONData.ResultSet.price_4_1 +"лв.<br>";
			document.getElementById('VP').innerHTML +="Втора Вноска: "+JSONData.ResultSet.price_4_2 +"лв.<br>";
			document.getElementById('VP').innerHTML +="Трета Вноска: "+JSONData.ResultSet.price_4_2 +"лв.<br>";
			document.getElementById('VP').innerHTML +="Четвърта Вноска: "+JSONData.ResultSet.price_4_2 +"лв.<br>";
			document.getElementById('VP').innerHTML +="Крайна Цена: <b>"+JSONData.ResultSet.price_4 +"лв.</b><br>";
		}
		//document.getElementById('VP').innerHTML +="<br><b>"+JSONData.ResultSet.Dostavka+"</b><br>";
		
		try{
			the_div=document.getElementById('VPFContact');
			t=the_div.innerHTML;
			//alert(t);
			//alert("cleare"+'VPF'+formHolderId);
			maps_div=document.getElementById('mapsDiv');
			document.getElementById('buttonProcesingContactForm').style.display='none';
			document.getElementById('buttonSendContactForm').style.display='';
			if(JSONData.ResultSet.City =='6'){				
				if(document.getElementById('agent_id').value!=2)maps_div.innerHTML ='<br><br>Ако желаете заповядайте в нашите офиси: <br><table cellspacing="0"><tr><td>бул. Сливница 52, срещу Варчев</td><td>ж.к. Чайка бл. 186</td></tr>'+
			'<tr><td><iframe width="370" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?source=s_q&amp;hl=en&amp;geocode=&amp;aq=&amp;ie=UTF8&amp;hq=&amp;hnear=Varna,+Varna+Province,+Bulgaria&amp;msa=0&amp;msid=213900201788441575943.0004a028a09975380d73a&amp;ll=43.210212,27.914994&amp;spn=0.002737,0.00456&amp;z=17&amp;iwloc=0004a028a4368dea0fa9f&amp;output=embed"></iframe></td>'+
			'<td><iframe width="370" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?source=s_q&amp;hl=en&amp;geocode=&amp;aq=&amp;ie=UTF8&amp;hq=&amp;hnear=Varna,+Varna+Province,+Bulgaria&amp;msa=0&amp;msid=213900201788441575943.0004a028aaa8d4096dc9b&amp;ll=43.216397,27.943254&amp;spn=0.002737,0.00456&amp;z=17&amp;iwloc=0004a028b1e02f5f846da&amp;output=embed"></iframe></td></tr></table>';
		
			}else if(JSONData.ResultSet.City =='16'){
			if(document.getElementById('agent_id').value!=2)maps_div.innerHTML ='<br><br>Ако желаете заповядайте в нашето представителство: <br><table cellspacing="0"><tr><td>Добрич, бул 25 Септември автокъща Джи Aуто</td></tr>'+
			'<tr><td><iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?msa=0&amp;msid=213900201788441575943.0004b40f23fa4450d4c08&amp;ie=UTF8&amp;ll=43.546239,27.822299&amp;spn=0,0&amp;t=h&amp;vpsrc=1&amp;output=embed"></iframe><br /><small>Вижте <a href="http://maps.google.com/maps/ms?msa=0&amp;msid=213900201788441575943.0004b40f23fa4450d4c08&amp;ie=UTF8&amp;ll=43.546239,27.822299&amp;spn=0,0&amp;t=h&amp;vpsrc=1&amp;source=embed" style="color:#0000FF;text-align:left">Гет Консулт Добрич</a> на по-голяма карта</small></td>'+
			'</tr></table>';
		
			}else if(JSONData.ResultSet.City =='34'){
			if(document.getElementById('agent_id').value!=2)maps_div.innerHTML +='<br><br>Ако желаете заповядайте в нашите офиси: <br><table cellspacing="0"><tr><td> гр. Разград бул. Априлско въстание 3 Кат или бул. Априлско въстание 66 Ром Петрол</td></tr>'+
			'<tr><td><iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?msa=0&amp;msid=213900201788441575943.0004b41ebb82edafa689c&amp;ie=UTF8&amp;t=m&amp;vpsrc=6&amp;ll=43.526522,26.515417&amp;spn=0.010891,0.018239&amp;z=15&amp;output=embed"></iframe><br /><small>Вижте <a href="http://maps.google.com/maps/ms?msa=0&amp;msid=213900201788441575943.0004b41ebb82edafa689c&amp;ie=UTF8&amp;t=m&amp;vpsrc=6&amp;ll=43.526522,26.515417&amp;spn=0.010891,0.018239&amp;z=15&amp;source=embed" style="color:#0000FF;text-align:left">Гет Консулт Разград - Ром Петрол</a> на по-голяма карта</small></td>'+
			'</tr></table>';
			}else maps_div.innerHTML='';
			//alert(t);
		}catch(err){
			var the_div=document.createElement("div");
			the_div.setAttribute('id','VPFContact');
			cnt=1*JSONData.ResultSet.totalResultsReturned;
			var the_form=document.createElement("form");
			the_form.setAttribute('name',JSONData.ResultSet.formName);
			the_form.setAttribute('class','VPF');
			the_form.setAttribute('className','VPF');
			var table_form=document.createElement("table");
			var table_head=document.createElement("thead");
			table_form.appendChild(table_head);	
			var table_body=document.createElement("tbody");
			for (i=0; i<cnt; i++){
				var tr= document.createElement("tr");
				var td= document.createElement("td");
				var abrv=document.createTextNode(JSONData.ResultSet.Result[i].field_abrv);			
				td.appendChild(abrv);
				if(JSONData.ResultSet.Result[i].field_mandatory=='1'){
					var span=document.createElement("span");
					var t=document.createTextNode('*');
					span.appendChild(t);
					td.appendChild(span);
				}
				td.setAttribute('class','abrv');
				td.setAttribute('className','abrv');
				tr.appendChild(td);
				var td= document.createElement("td");
				/*str=JSONData.ResultSet.Result[i].field_value;
				str=str.replace(/\[/gi,"<");
				td.innerHTML=str.replace(/\]/gi,">");*/
				var inp=document.createElement("input");
				inp.setAttribute('type','text');
				inp.setAttribute('id',JSONData.ResultSet.Result[i].field_id);
				inp.setAttribute('name',JSONData.ResultSet.Result[i].field_id);
				inp.setAttribute('value',JSONData.ResultSet.Result[i].field_value);
				td.appendChild(inp);
				tr.appendChild(td);
				table_body.appendChild(tr);
			}
			var  tr= document.createElement("tr");
			var td= document.createElement("td");
			tr.appendChild(td);
			var td= document.createElement("td");
			var button= document.createElement("input");
			button.setAttribute('value','Продължи');
			button.setAttribute('type','button');
			button.setAttribute('id','buttonSendContactForm');
			addEvent(button, 'click', eval(JSONData.ResultSet.formValidate), false);
			//alert(JSONData.ResultSet.formValidate);
			td.appendChild(button);
			var procesing= document.createElement("input");
			procesing.setAttribute('value','Обработка на данните');
			procesing.setAttribute('type','button');
			procesing.setAttribute('id','buttonProcesingContactForm');
			procesing.style.display='none';
			td.appendChild(procesing);
			tr.appendChild(td);
			table_body.appendChild(tr);
			table_form.appendChild(table_body);
			the_form.appendChild(table_form);
			the_div.appendChild(the_form);
			document.getElementById("contacts_details_form").appendChild(the_div);
			
			if(JSONData.ResultSet.City =='6'){
				var maps_div=document.createElement("div");
				maps_div.setAttribute('id','mapsDiv');
				maps_div.style.width="700px";
				maps_div.innerHTML +='<br><br> Ако желаете заповядайте в нашите офиси: <br><table cellspacing="0"><tr><td>бул. Сливница 52, срещу Варчев</td><td>ж.к. Чайка бл. 186</td></tr>'+
			'<tr><td><iframe width="370" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?source=s_q&amp;hl=en&amp;geocode=&amp;aq=&amp;ie=UTF8&amp;hq=&amp;hnear=Varna,+Varna+Province,+Bulgaria&amp;msa=0&amp;msid=213900201788441575943.0004a028a09975380d73a&amp;ll=43.210212,27.914994&amp;spn=0.002737,0.00456&amp;z=17&amp;iwloc=0004a028a4368dea0fa9f&amp;output=embed"></iframe></td>'+
			'<td><iframe width="370" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?source=s_q&amp;hl=en&amp;geocode=&amp;aq=&amp;ie=UTF8&amp;hq=&amp;hnear=Varna,+Varna+Province,+Bulgaria&amp;msa=0&amp;msid=213900201788441575943.0004a028aaa8d4096dc9b&amp;ll=43.216397,27.943254&amp;spn=0.002737,0.00456&amp;z=17&amp;iwloc=0004a028b1e02f5f846da&amp;output=embed"></iframe></td></tr></table>';
		
				if(document.getElementById('agent_id').value!=2)document.getElementById("contacts_details_form").appendChild(maps_div);
				
			}else if(JSONData.ResultSet.City =='16'){
				var maps_div=document.createElement("div");
				maps_div.setAttribute('id','mapsDiv');
				maps_div.style.width="700px";
				maps_div.innerHTML +='<br><br>Ако желаете заповядайте в нашето представителство: <br><table cellspacing="0"><tr><td>Добрич, бул 25 Септември автокъща Джи Aуто</td></tr>'+
			'<tr><td><iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?msa=0&amp;msid=213900201788441575943.0004b40f23fa4450d4c08&amp;ie=UTF8&amp;ll=43.546239,27.822299&amp;spn=0,0&amp;t=h&amp;vpsrc=1&amp;output=embed"></iframe><br /><small>Вижте <a href="http://maps.google.com/maps/ms?msa=0&amp;msid=213900201788441575943.0004b40f23fa4450d4c08&amp;ie=UTF8&amp;ll=43.546239,27.822299&amp;spn=0,0&amp;t=h&amp;vpsrc=1&amp;source=embed" style="color:#0000FF;text-align:left">Гет Консулт Добрич</a> на по-голяма карта</small></td>'+
			'</tr></table>';
		
				if(document.getElementById('agent_id').value!=2)document.getElementById("contacts_details_form").appendChild(maps_div);
				
			}else if(JSONData.ResultSet.City =='34'){
				var maps_div=document.createElement("div");
				maps_div.setAttribute('id','mapsDiv');
				maps_div.style.width="700px";
				maps_div.innerHTML +='<br><br>Ако желаете заповядайте в нашите офиси: <br><table cellspacing="0"><tr><td> гр. Разград бул. Априлско въстание 3 Кат или бул. Априлско въстание 66 Ром Петрол</td></tr>'+
			'<tr><td><iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?msa=0&amp;msid=213900201788441575943.0004b41ebb82edafa689c&amp;ie=UTF8&amp;t=m&amp;vpsrc=6&amp;ll=43.526522,26.515417&amp;spn=0.010891,0.018239&amp;z=15&amp;output=embed"></iframe><br /><small>Вижте <a href="http://maps.google.com/maps/ms?msa=0&amp;msid=213900201788441575943.0004b41ebb82edafa689c&amp;ie=UTF8&amp;t=m&amp;vpsrc=6&amp;ll=43.526522,26.515417&amp;spn=0.010891,0.018239&amp;z=15&amp;source=embed" style="color:#0000FF;text-align:left">Гет Консулт Разград - Ром Петрол</a> на по-голяма карта</small></td>'+
			'</tr></table>';
		
				if(document.getElementById('agent_id').value!=2)document.getElementById("contacts_details_form").appendChild(maps_div);
				
			}else{
				var maps_div=document.createElement("div");
				maps_div.setAttribute('id','mapsDiv');
				maps_div.style.width="700px";
				maps_div.innerHTML ='';
				if(document.getElementById('agent_id').value!=2)document.getElementById("contacts_details_form").appendChild(maps_div);
			}
		}
}


function contactDetailsKasko(JSONData){
	 if (JSONData != null){
		document.getElementById('getins_title_popup').innerHTML='Данни за Контакт';
		listFormDetails(JSONData);		
	 }
}

function wonerDetails(JSONData){
	 if (JSONData != null){		
		listFormDetailsOwner(JSONData);		
	 }
}

function driverDetails(JSONData){
	 if (JSONData != null){
		listFormDetailsDriver(JSONData);		
	 }
}
function mpsDetails(JSONData){
	 if (JSONData != null){
		listFormDetailsMPS(JSONData);		
	 }
}
function listFormDetailsOwner(JSONData){
	document.getElementById("view_contact_details").style.display="none";	
	document.getElementById("view_owner_details").style.display="";
	document.getElementById('FTanks').innerHTML='<p>Г-н/Гжо <b>'+document.getElementById('name_client').value+
	'</b>,<br>Вашето запитване е получено. Ние ще се свържем с Вас на тел: '+document.getElementById('phone').value+' за потвържднеие на запитването.<br>'+
	'На посочения от Вас Е-мейл: '+document.getElementById('email').value+' ще получите сакнирана Полица след потвърждение на заявката.<br>'+
	'Ако имате възможност моля продължете с попълването на данните за собственик, обичаен водач и детайли на автомобила с цел избягване на грешки '+
	'и по бърза подготовка на полицата. <br>Благодарим Ви предварително.<br><br></p><h4>Детайли на Вашата заявка до момента</h4>'+document.getElementById('VP').innerHTML;
	document.getElementById('owner_details_form').style.width='760px';
	listFormDetailsNewN("owner_details_form",JSONData);	
	$(function() {
			$( "#start_drive_owner" ).datepicker();
		});
	
}
function listFormDetailsDriver(JSONData){
	document.getElementById("view_owner_details").style.display="none";
	document.getElementById('driver_details_form').style.width='760px';
	document.getElementById("view_driver_details").style.display="";
	document.getElementById('ownerTanks').innerHTML='<h4>Детайли на Вашата заявка до момента</h4>'+document.getElementById('VP').innerHTML;
	if(document.getElementById('owner_name').value!='')document.getElementById('ownerTanks').innerHTML+= 'Собственик:'+document.getElementById('owner_name').value+"<br>";
	if(document.getElementById('owner_region').value!='')document.getElementById('ownerTanks').innerHTML+='Област:'+document.getElementById('owner_region').value+"<br>";
	if(document.getElementById('owner_city').value!='')document.getElementById('ownerTanks').innerHTML+='Населено място:'+document.getElementById('owner_city').value+"<br>";
	if(document.getElementById('owner_address').value!='')document.getElementById('ownerTanks').innerHTML+='Адрес на собственик по талон:'+document.getElementById('owner_address').value+"<br>";
	
	listFormDetailsNewN("driver_details_form",JSONData);
	$(function() {
			$( "#start_drive_driver" ).datepicker();
		});
}

function listFormDetailsMPS(JSONData){
	document.getElementById("view_driver_details").style.display="none";
	document.getElementById('mps_details_form').style.width='760px';
	document.getElementById("view_mps_details").style.display="";
	document.getElementById('driverTanks').innerHTML=document.getElementById('ownerTanks').innerHTML;
	if(document.getElementById('driver_name').value!='') document.getElementById('driverTanks').innerHTML +='Обичаен Водач:'+document.getElementById('driver_name').value+"<br>";	
	if(document.getElementById('driver_region').value!='')document.getElementById('driverTanks').innerHTML +='Област:'+document.getElementById('driver_region').value+"<br>";
	if(document.getElementById('driver_city').value!='')document.getElementById('driverTanks').innerHTML +='Населено място:'+document.getElementById('driver_city').value+"<br>";
	if(document.getElementById('driver_address').value!='')document.getElementById('driverTanks').innerHTML +='Адрес на водача:'+document.getElementById('driver_address').value+"<br>";
	listFormDetailsNewN("mps_details_form",JSONData);
	$(function() {
			$( "#reg_date_mps" ).datepicker();
		});
}

function listFormDetailsNewN(formHolderId,JSONData){
		var formHolder=document.getElementById(formHolderId);
		formHolder.style.display='';
		//formHolder.innerHTML='';
		cnt=1*JSONData.ResultSet.totalResultsReturned;
		try{
			document.getElementById('VPF'+formHolderId).innerHTML ='';
			the_div=document.getElementById('VPF'+formHolderId);
			//alert("cleare"+'VPF'+formHolderId);
		}catch(err){
			//alert("create"+'VPF'+formHolderId);
			var the_div=document.createElement("div");
			the_div.setAttribute('id','VPF'+formHolderId);
		}
			var the_form=document.createElement("form");
			//the_form.setAttribute('id','VPF');
			the_form.setAttribute('class','VPF');
			the_form.setAttribute('className','VPF');
			the_form.setAttribute('name',JSONData.ResultSet.formName);
			var table_form=document.createElement("table");
			var table_head=document.createElement("thead");
			table_form.appendChild(table_head);	
			var table_body=document.createElement("tbody");
			for (i=0; i<cnt; i++){
				var  tr= document.createElement("tr");
				var td= document.createElement("td");
				var abrv=document.createTextNode(JSONData.ResultSet.Result[i].field_abrv);			
				td.appendChild(abrv);
				if(JSONData.ResultSet.Result[i].field_mandatory=='1'){
					var span=document.createElement("span");
					var t=document.createTextNode('*');
					span.appendChild(t);
					td.appendChild(span);
				}
				td.setAttribute('className','abrv');
				tr.appendChild(td);
				var td= document.createElement("td");
				
				/*str=JSONData.ResultSet.Result[i].field_value;
				str=str.replace(/\[/gi,"<");
				td.innerHTML=str.replace(/\]/gi,">");*/
				try{
					//alert(JSONData.ResultSet.Result[i].field_element)
					if(JSONData.ResultSet.Result[i].field_element=="text"){
						var inp=document.createElement("input");
						inp.setAttribute('type','text');
						inp.setAttribute('id',JSONData.ResultSet.Result[i].field_id);
						inp.setAttribute('name',JSONData.ResultSet.Result[i].field_id);
						inp.setAttribute('value',JSONData.ResultSet.Result[i].field_value);
					}else if(JSONData.ResultSet.Result[i].field_element=="select"){
						var inp=document.createElement("select");
						opt_cnt=1*JSONData.ResultSet.Result[i].options_cnt;
						inp.setAttribute('id',JSONData.ResultSet.Result[i].field_id);
						inp.setAttribute('name',JSONData.ResultSet.Result[i].field_id);
						for(l=0;l<opt_cnt;l++){
							opt=document.createElement("option");
							opt.setAttribute('value',JSONData.ResultSet.Result[i].options[l].option_value);
							var optt=document.createTextNode(JSONData.ResultSet.Result[i].options[l].option_printed);
							opt.appendChild(optt);
							inp.appendChild(opt);							
						}
						//inp.setAttribute('type','text');
						
						//inp.setAttribute('value',JSONData.ResultSet.Result[i].field_value);
						
					}
				}catch(err){
					var inp=document.createElement("input");
					inp.setAttribute('type','text');
					inp.setAttribute('id',JSONData.ResultSet.Result[i].field_id);
					inp.setAttribute('name',JSONData.ResultSet.Result[i].field_id);
					inp.setAttribute('value',JSONData.ResultSet.Result[i].field_value);
				}
				td.appendChild(inp);
				tr.appendChild(td);
				table_body.appendChild(tr);
			}
			var  tr= document.createElement("tr");
			var td= document.createElement("td");
			tr.appendChild(td);
			var td= document.createElement("td");
			var button= document.createElement("input");
			button.setAttribute('value','Продължи');
			button.setAttribute('type','button');
			button.setAttribute('id','buttonSend'+formHolderId);
			//var t=document.createTextNode("Продължи");
			//button.appendChild(t);
			addEvent(button, 'click', eval(JSONData.ResultSet.formValidate), false);
			td.appendChild(button);
			var procesing= document.createElement("input");
			procesing.setAttribute('value','Обработка на данните');
			procesing.setAttribute('type','button');
			procesing.setAttribute('id','buttonProcesing'+formHolderId);
			procesing.style.display='none';
			td.appendChild(procesing);
			tr.appendChild(td);
			table_body.appendChild(tr);
			table_form.appendChild(table_body);
			the_form.appendChild(table_form);
			the_div.appendChild(the_form);
			formHolder.appendChild(the_div);
		
}

function listFormDetailsNew(JSONData){		
		document.getElementById("view_price_container").style.display='none';
		//document.getElementById("table_actualni_ceni").style.display='none';
		document.getElementById("contacts_details_form").style.display='';
		//document.getElementById("table_cont_details").style.display='';
		//document.getElementById("view_price_head").style.width='800px';
		document.getElementById('contacts_details_form').innerHTML='<p style="text-align:left; margin:10px;">Вашето запитване е получено. Ако имате възможност моля продължете с попълването на данните за собственик, обичаен водач и детайли на автомобила с цел избягване на грешки и по бърза подготовка на полицата. <br>Благодарим Ви предварително.</p>';
		cnt=1*JSONData.ResultSet.totalResultsReturned;
		var the_form=document.createElement("form");
		the_form.setAttribute('name',JSONData.ResultSet.formName);
		var table_form=document.createElement("table");
		var table_head=document.createElement("thead");
		table_form.appendChild(table_head);	
		var table_body=document.createElement("tbody");
		for (i=0; i<cnt; i++){
			var  tr= document.createElement("tr");
			var td= document.createElement("td");
			var abrv=document.createTextNode(JSONData.ResultSet.Result[i].field_abrv);			
			td.appendChild(abrv);
			if(JSONData.ResultSet.Result[i].field_mandatory=='1'){
				var span=document.createElement("span");
				var t=document.createTextNode('*');
				span.appendChild(t);
				td.appendChild(span);
			}
			td.setAttribute('className','abrv');
			tr.appendChild(td);
			var td= document.createElement("td");
			var inp=document.createElement("input");
			inp.setAttribute('type','text');
			inp.setAttribute('id',JSONData.ResultSet.Result[i].field_id);
			inp.setAttribute('name',JSONData.ResultSet.Result[i].field_id);
			inp.setAttribute('value',JSONData.ResultSet.Result[i].field_value);
			td.appendChild(inp);
			tr.appendChild(td);
			table_body.appendChild(tr);
		}
		var  tr= document.createElement("tr");
		var td= document.createElement("td");
		tr.appendChild(td);
		var td= document.createElement("td");
		var button= document.createElement("input");
		button.setAttribute('value','Продължи');
		button.setAttribute('type','button');
		button.setAttribute('id','buttonSend');
		//var t=document.createTextNode("Продължи");
		//button.appendChild(t);
		addEvent(button, 'click', eval(JSONData.ResultSet.formValidate), false);
		td.appendChild(button);
			var procesing= document.createElement("input");
		procesing.setAttribute('value','Обработка на данните');
		procesing.setAttribute('type','button');
		procesing.setAttribute('id','buttonProcesing');
		procesing.style.display='none';
		td.appendChild(procesing);
		tr.appendChild(td);
		table_body.appendChild(tr);
		table_form.appendChild(table_body);
		the_form.appendChild(table_form);
		document.getElementById("contacts_details_form").appendChild(the_form);
}
function listFormDetails(JSONData){
		
		document.getElementById("view_price_container").style.display='none';
		document.getElementById("table_actualni_ceni").style.display='none';
		document.getElementById("contacts_details_form").style.display='';
		//document.getElementById("table_cont_details").style.display='';
		//document.getElementById("view_price_head").style.width='800px';
		document.getElementById('contacts_details_form').style.width='800px';
		document.getElementById('contacts_details_form').innerHTML='';
		cnt=1*JSONData.ResultSet.totalResultsReturned;
		var the_form=document.createElement("form");
		the_form.setAttribute('name',JSONData.ResultSet.formName);
		the_form.setAttribute('id','VPF');
		var table_form=document.createElement("table");
		var table_head=document.createElement("thead");
		table_form.appendChild(table_head);	
		var table_body=document.createElement("tbody");
		for (i=0; i<cnt; i++){
			var  tr= document.createElement("tr");
			var td= document.createElement("td");
			var abrv=document.createTextNode(JSONData.ResultSet.Result[i].field_abrv);			
			td.appendChild(abrv);
			if(JSONData.ResultSet.Result[i].field_mandatory=='1'){
				var span=document.createElement("span");
				var t=document.createTextNode('*');
				span.appendChild(t);
				td.appendChild(span);
			}
			td.setAttribute('className','abrv');
			tr.appendChild(td);
			var td= document.createElement("td");
			var inp=document.createElement("input");
			inp.setAttribute('type','text');
			inp.setAttribute('id',JSONData.ResultSet.Result[i].field_id);
			inp.setAttribute('name',JSONData.ResultSet.Result[i].field_id);
			inp.setAttribute('value',JSONData.ResultSet.Result[i].field_value);
			td.appendChild(inp);
			tr.appendChild(td);
			table_body.appendChild(tr);
		}
		var  tr= document.createElement("tr");
		var td= document.createElement("td");
		tr.appendChild(td);
		var td= document.createElement("td");
		var button= document.createElement("input");
		button.setAttribute('value','Продължи');
		button.setAttribute('type','button');
		button.setAttribute('id','buttonSend');
		//var t=document.createTextNode("Продължи");
		//button.appendChild(t);
		addEvent(button, 'click', eval(JSONData.ResultSet.formValidate), false);
		td.appendChild(button);
			var procesing= document.createElement("input");
		procesing.setAttribute('value','Обработка на данните');
		procesing.setAttribute('type','button');
		procesing.setAttribute('id','buttonProcesing');
		procesing.style.display='none';
		td.appendChild(procesing);
		tr.appendChild(td);
		table_body.appendChild(tr);
		table_form.appendChild(table_body);
		the_form.appendChild(table_form);
		document.getElementById("contacts_details_form").appendChild(the_form);
}


function registerGo(JSONData){
	 if (JSONData != null){
		document.getElementById("view_mps_details").style.display='none';
		document.getElementById("view_thank_page").style.display='';
		//document.getElementById("table_cont_details").style.display='';
		//document.getElementById("view_price_head").style.width='800px';
		document.getElementById('thank_details_form').innerHTML='';
		var p_thank=document.createElement("p");
		var thank_txt=document.createTextNode(JSONData.ResultSet.thank_txt);
		p_thank.appendChild(thank_txt);	
		document.getElementById("thank_details_form").appendChild(p_thank);	
		cnt=1*JSONData.ResultSet.totalResultsReturned;
		var table_form=document.createElement("table");
		var table_head=document.createElement("thead");
		table_form.appendChild(table_head);	
		var table_body=document.createElement("tbody");
		for (i=0; i<cnt; i++){
			if(JSONData.ResultSet.Result[i].field_value!='' && JSONData.ResultSet.Result[i].field_value!='0'){
				var  tr= document.createElement("tr");
				var td= document.createElement("td");
				var abrv=document.createTextNode(JSONData.ResultSet.Result[i].field_name);			
				td.appendChild(abrv);			
				tr.appendChild(td);
				var td= document.createElement("td");
				var abrv=document.createTextNode(JSONData.ResultSet.Result[i].field_value);
				td.appendChild(abrv);			
				tr.appendChild(td);
				table_body.appendChild(tr);
			}
		}	
		table_form.appendChild(table_body);
		document.getElementById("thank_details_form").appendChild(table_form);	
	 }
}


function registerKasko(JSONData){
	 if (JSONData != null){
		document.getElementById('getins_title_popup').innerHTML='Приета заявка';
		document.getElementById("view_price_container").style.display='none';
		document.getElementById("table_actualni_ceni").style.display='none';
		document.getElementById("contacts_details_form").style.display='';
		//document.getElementById("table_cont_details").style.display='';
		//document.getElementById("view_price_head").style.width='800px';
		document.getElementById('contacts_details_form').innerHTML='';
		var p_thank=document.createElement("p");
		p_thank.style.width='700px';
		var thank_txt=document.createTextNode(JSONData.ResultSet.thank_txt);
		p_thank.appendChild(thank_txt);	
		document.getElementById("contacts_details_form").appendChild(p_thank);	
		cnt=1*JSONData.ResultSet.totalResultsReturned;
		var table_form=document.createElement("table");
		var table_head=document.createElement("thead");
		table_form.appendChild(table_head);	
		var table_body=document.createElement("tbody");
		for (i=0; i<cnt; i++){
			if(JSONData.ResultSet.Result[i].field_value!='' && JSONData.ResultSet.Result[i].field_value!='0'){
				var  tr= document.createElement("tr");
				var td= document.createElement("td");
				var abrv=document.createTextNode(JSONData.ResultSet.Result[i].field_name);			
				td.appendChild(abrv);			
				tr.appendChild(td);
				var td= document.createElement("td");
				//var abrv=document.createTextNode(JSONData.ResultSet.Result[i].field_value);
				td.innerHTML=JSONData.ResultSet.Result[i].field_value;
				//td.appendChild(abrv);			
				tr.appendChild(td);
				table_body.appendChild(tr);
			}
		}	
		table_form.appendChild(table_body);
		document.getElementById("contacts_details_form").appendChild(table_form);	
	 }
}

function viewGoList(listId){
	for(i=1;i<=4;i++){
		if(i==listId){
			document.getElementById('golist'+i).className='go1v';
			document.getElementById('GOT'+i).style.display='';
		}else{
			document.getElementById('golist'+i).className='go2v';
			document.getElementById('GOT'+i).style.display='none';
		}
	}
	switch(listId){
	case 1: 
		
	break;
	case 2: break;
	case 3: break;
	case 4: break;
	}
}
function close_contact_details(){
	document.getElementById("view_contact_details").style.display="none";
	document.getElementById("view_price_container").style.display="";
}
function close_owner_details(){
	document.getElementById("view_owner_details").style.display="none";
	document.getElementById("view_contact_details").style.display="";
	document.getElementById('buttonSendContactForm').style.display='';
	document.getElementById('buttonProcesingContactForm').style.display='none';
}
function close_driver_details(){
	document.getElementById("view_driver_details").style.display="none";
	document.getElementById("view_owner_details").style.display="";
	document.getElementById('buttonSendowner_details_form').style.display='';
	document.getElementById('buttonProcesingowner_details_form').style.display='none';
}
function close_mps_details(){
	document.getElementById("view_mps_details").style.display="none";
	document.getElementById("view_driver_details").style.display="";
	document.getElementById('buttonSenddriver_details_form').style.display='';
	document.getElementById('buttonProcesingdriver_details_form').style.display='none';
}
function viewPriceGONew(JSONData) {
	 if (JSONData != null){
		contr_id='view_price_container';
		var contr=document.getElementById(contr_id);
		//alert(contr.innerHTML);
		contr.innerHTML ='<div id="type_payments">'+
		'<a href="javascript:viewGoList(1)" id="golist1" class="go1v" onclick="viewGoList(1);">Еднократно Плащане</a>'+
		'<a href="javascript:viewGoList(2)" id="golist2" class="go2v" viewGoList(1)>Плащане на две вноски</a>'+
		'<a href="javascript:viewGoList(3)" id="golist3"class="go2v" viewGoList(1)>Плащане на три вноски</a>'+
		'<a href="javascript:viewGoList(4)" id="golist4" class="go2v" viewGoList(1)>Плащане на четири вноски</a></div>';
		var dd = new Date();
		var hh=dd.getHours();
		if(JSONData.ResultSet.city_id==6){
			if(hh>=9 && hh<17){
				document.getElementById('sels_benefit').innerHTML='<h3>GetIns.bg Ви предлага най-добри цени ПЛЮС</h3>'+
					'<ol>'+							
						'<li>Потвърждаване на заявката до 15 минути от наш служител</li>'+
						'<li>Плащане при получаване на полицата</li>'+
						'<li>Безплатна доставка до <b>два часа на удобно за Вас място</b></li>'+
						'<li>Известяване за изтичаща полица или вноска</li>'+
					'</ol>';
			}else if(hh>17){
				document.getElementById('sels_benefit').innerHTML='<h3>GetIns.bg Ви предлага най-добри цени ПЛЮС</h3>'+
					'<ol>'+							
						'<li>Потвърждаване на заявката на следващия работен ден от наш служител</li>'+
						'<li>Плащане при получаване на полицата</li>'+
						'<li>Безплатна доставка до <b>два часа на удобно за Вас място</b> след потвърждаване на заявката</li>'+
						'<li>Известяване за изтичаща полица или вноска</li>'+
					'</ol>';
			}else{
				document.getElementById('sels_benefit').innerHTML='<h3>GetIns.bg Ви предлага най-добри цени ПЛЮС</h3>'+
					'<ol>'+							
						'<li>Потвърждаване на заявката след 9.00 часа от наш служител</li>'+
						'<li>Плащане при получаване на полицата</li>'+
						'<li>Безплатна доставка до <b>два часа на удобно за Вас място</b> след потвърждаване на заявката</li>'+
						'<li>Известяване за изтичаща полица или вноска</li>'+
					'</ol>';
			}
		}else{
			document.getElementById('h2ceni').innerHTML='Актуални цени - Безплатна Доставка на Полицата до 24 часа';
			if(hh>=9 && hh<17){
					benefit='<h3>GetIns.bg Ви предлага най-добри цени ПЛЮС</h3>'+
					'<ol>'+							
						'<li>Потвърждаване на заявката до 15 минути от наш служител</li>'+
						'<li>Получавате сканирано копие на полицата на Е-мейл до 30 минути след потвърждаване на заявката</li>'+
						'<li>Плащане при получаване на полицата</li>';
					switch(dd.getDay()){
						case 0: 
							benefit +='<li>Безплатна доставка във Вторник в удобно за Вас време и място</li>';
						break;
						case 1: 
							benefit +='<li>Безплатна доставка на следващия работен ден в удобно за Вас време и място</li>';
						break;
						case 2: 
							benefit +='<li>Безплатна доставка на следващия работен ден в удобно за Вас време и място</li>';
						break;
						case 3: 
							benefit +='<li>Безплатна доставка на следващия работен ден в удобно за Вас време и място</li>';
						break;
						case 4: 
							benefit +='<li>Безплатна доставка на следващия работен ден в удобно за Вас време и място</li>';
						break;
						case 5: 
							benefit +='<li><b>Безплатна доставка в Събота до обяд</b></li>';
						break;
						case 6: 
							if(hh<13) benefit +='<li>Безплатна доставка във Понеделник в удобно за Вас време и място</li>';
							else benefit +='<li>Безплатна доставка във Вторник в удобно за Вас време и място</li>';
						break;
					}	
					
					benefit +=	'<li>Онлайн проследяване на пратката</li>'+
						'<li>Известяване за изтичаща полица или вноска</li>'+
					'</ol>';
					document.getElementById('sels_benefit').innerHTML=benefit;
			}else if(hh>17){
				document.getElementById('sels_benefit').innerHTML='<h3>GetIns.bg Ви предлага най-добри цени ПЛЮС</h3>'+
					'<ol>'+							
						'<li>Потвърждаване на заявката от наш служител</li>'+
						'<li>Получавате сканирано копие на полицата на Е-мейл до 30 минути след потвърждаване на заявката</li>'+
						'<li>Плащане при получаване на полицата</li>'+
						'<li>Безплатна доставка <b>до 24 часа след потвърждаване на заявката в удобно за Вас време и място</b></li>'+
						'<li>Онлайн проследяване на пратката</li>'+
						'<li>Известяване за изтичаща полица или вноска</li>'+
					'</ol>';
			}else{
				document.getElementById('sels_benefit').innerHTML='<h3>GetIns.bg Ви предлага най-добри цени ПЛЮС</h3>'+
					'<ol>'+							
						'<li>Потвърждаване на заявката от наш служител</li>'+
						'<li>Получавате сканирано копие на полицата на Е-мейл до 30 минути след потвърждаване на заявката</li>'+
						'<li>Плащане при получаване на полицата</li>'+
						'<li>Безплатна доставка <b>до 24 часа след потвърждаване на заявката в удобно за Вас време и място</b></li>'+
						'<li>Онлайн проследяване на пратката</li>'+
						'<li>Известяване за изтичаща полица или вноска</li>'+
					'</ol>';			
			}
		}
		
		//ednokratno
		var d1=document.createElement("div");
		contr.appendChild(d1);
		d1.setAttribute('id','GOTableHold');
		var contr=d1;
		cnt=1*JSONData.ResultSet.totalResultsReturned;		
		var table_prices=document.createElement("table");
		table_prices.setAttribute('id','GOT1');
		table_prices.setAttribute("cellPadding", "0");
		table_prices.setAttribute("cellSpacing", "0");
		var table_head=document.createElement("thead");
		table_prices.appendChild(table_head);	
		var table_body=document.createElement("tbody");		
		for (i=0; i<cnt; i++){			
			//izpisvane imeto na companiyata
			var td= document.createElement("td");
			var t=document.createTextNode(JSONData.ResultSet.Result[i].CompanyName);
		  	td.appendChild(t);
			
				td.setAttribute('class','td_company_name');
				td.setAttribute('className','td_company_name');
			
			var  tr= document.createElement("tr");
			if(i==0){
				tr.setAttribute('class','top_oferta');
				tr.setAttribute('className','top_oferta');
			}
			
			tr.appendChild(td);
			
			var td= document.createElement("td");
			if(i==0) var t=document.createTextNode("ТОП ЦЕНА");
			else var t=document.createTextNode("Цена");
		  	td.appendChild(t);
			td.setAttribute('class','td_pp');
			td.setAttribute('className','td_pp');
			tr.appendChild(td);
			
			var td= document.createElement("td");
			var t=document.createTextNode("");
		  	td.appendChild(t);
			td.setAttribute('class','td_pi');
			td.setAttribute('className','td_pi');
			tr.appendChild(td);
			
			table_body.appendChild(tr);
			
			var  tr= document.createElement("tr");
			if(i==0){
				tr.setAttribute('class','top_oferta');
				tr.setAttribute('className','top_oferta');
			}
			var  td= document.createElement("td");
			var img=document.createElement("img");
			img.src='http://www.getins.bg/images/loga/'+JSONData.ResultSet.Result[i].logo;
			td.appendChild(img);
			td.setAttribute('class','td_logo');
			td.setAttribute('className','td_logo');
			tr.appendChild(td);
			
			
			var  td= document.createElement("td");
			var t=document.createTextNode(JSONData.ResultSet.Result[i].price_d_1_1+" лв.");
			td.appendChild(t);
			tr.appendChild(td);
			td.setAttribute('class','vn1');
			td.setAttribute('className','vn1');
			
			var  td= document.createElement("td");
			var  button= document.createElement("input");
			//var t=document.createTextNode("ЗАЯВКА ЗА ПОЛИЦА");
			//button.appendChild(t);
			button.setAttribute('type', 'image');
			button.src= 'images1/bay.png';
			button.setAttribute('id', 'but_'+JSONData.ResultSet.Result[i].Id+'_1');
			td.appendChild(button);
			td.setAttribute('class','vn3');
			td.setAttribute('className','vn3');
			addEvent(button, 'click', choise_copmany_price, false);
			tr.appendChild(td);
			table_body.appendChild(tr);
			
			var  tr= document.createElement("tr");
			if(i==0){
				tr.setAttribute('class','top_oferta');
				tr.setAttribute('className','top_oferta');
			}
			var  td= document.createElement("td");
			td.innerHTML=JSONData.ResultSet.Result[i].descr;
			td.setAttribute('class','infoprice');
			td.setAttribute('className','infoprice');
			td.setAttribute('colSpan','3');
			tr.appendChild(td);
			table_body.appendChild(tr);
			
			var  tr= document.createElement("tr");
			var  td= document.createElement("td");
			td.setAttribute('class','trDel');
			td.setAttribute('className','trDel');
			td.setAttribute('colSpan','3');
			tr.appendChild(td);
			table_body.appendChild(tr);
		}
		
		table_prices.appendChild(table_body);
		contr.appendChild(table_prices);
		
		
		// na 2 vnoski
		var table_prices=document.createElement("table");
		table_prices.setAttribute('id','GOT2');
		table_prices.style.display="none";
		table_prices.setAttribute("cellPadding", "0");
		table_prices.setAttribute("cellSpacing", "0");
		var table_head=document.createElement("thead");
		table_prices.appendChild(table_head);	
		var table_body=document.createElement("tbody");	
		for (i=0; i<cnt; i++){	
			if(parseInt(JSONData.ResultSet.Result[i].price_d_2)>0){
				//izpisvane imeto na companiyata
				var td= document.createElement("td");
				var t=document.createTextNode(JSONData.ResultSet.Result[i].CompanyName);
				td.appendChild(t);
				//td.setAttribute('colSpan','5');
				td.setAttribute('class','td_company_name');
				td.setAttribute('className','td_company_name');
				var  tr= document.createElement("tr");
				if(i==0){
					tr.setAttribute('class','top_oferta');
					tr.setAttribute('className','top_oferta');
				}
				tr.appendChild(td);
				for(j=0;j<th_2.length;j++){
					var td=document.createElement("td");
					var t=document.createTextNode(th_2[j]);
					td.appendChild(t);
					td.setAttribute('class','td_pp');
					td.setAttribute('className','td_pp');
					tr.appendChild(td);
				};
				var td=document.createElement("td");
					
					td.setAttribute('class','td_pi');
					td.setAttribute('className','td_pi');
					tr.appendChild(td);
				table_body.appendChild(tr);
				
				var  tr= document.createElement("tr");
				if(i==0){
					tr.setAttribute('class','top_oferta');
					tr.setAttribute('className','top_oferta');
				}
				var  td= document.createElement("td");
				var img=document.createElement("img");
				img.src='http://www.getins.bg/images/loga/'+JSONData.ResultSet.Result[i].logo;
				td.appendChild(img);
				td.setAttribute('class','td_logo');
				td.setAttribute('className','td_logo');
				tr.appendChild(td);	
				
				
				var  td= document.createElement("td");
				var t=document.createTextNode(JSONData.ResultSet.Result[i].price_d_2_1+" лв.");
				td.appendChild(t);
				tr.appendChild(td);
				td.setAttribute('class','vn1');
				td.setAttribute('className','vn1');
				
				var  td= document.createElement("td");
				var t=document.createTextNode(JSONData.ResultSet.Result[i].price_d_2_2+" лв.");
				td.appendChild(t);
				tr.appendChild(td);
				td.setAttribute('class','vn1');
				td.setAttribute('className','vn1');
				
				var tdo = document.createElement('td');
				//var t=document.createTextNode(JSONData.ResultSet.Result[i].price_d_2+" лв.");
				//td.appendChild(t);
				tdo.innerHTML=JSONData.ResultSet.Result[i].price_d_2+" лв.";
				tr.appendChild(tdo);	
				tdo.setAttribute('class','vn1');
				tdo.setAttribute('className','vn1');
				
				var  td= document.createElement("td");
				if(JSONData.ResultSet.Result[i].price_2==0){
					var t=document.createTextNode("Не се предлага");
					td.appendChild(t);
				}else{
					var  button= document.createElement("input");
					//var t=document.createTextNode("ЗАЯВКА ЗА ПОЛИЦА");
					//button.appendChild(t);
					button.setAttribute('type', 'image');
					button.src= 'images1/bay.png';
					//button.appendChild(t);
					td.appendChild(button);
					addEvent(button, 'click', choise_copmany_price, false);
					button.setAttribute('id', 'but_'+JSONData.ResultSet.Result[i].Id+'_2');
				}
				td.setAttribute('class','vn3');
				td.setAttribute('className','vn3');
				tr.appendChild(td);
				
				table_body.appendChild(tr);
				
				var  tr= document.createElement("tr");
				if(i==0){
					tr.setAttribute('class','top_oferta');
					tr.setAttribute('className','top_oferta');
				}			
				var  td= document.createElement("td");
				td.innerHTML=JSONData.ResultSet.Result[i].descr;
				td.setAttribute('class','infoprice');
				td.setAttribute('className','infoprice');
				td.setAttribute('colSpan','5');
				tr.appendChild(td);
				table_body.appendChild(tr);
				
				var  tr= document.createElement("tr");
				var  td= document.createElement("td");
				td.setAttribute('class','trDel');
				td.setAttribute('className','trDel');
				td.setAttribute('colSpan','5');
				tr.appendChild(td);
				table_body.appendChild(tr);
			}
		}		
		table_prices.appendChild(table_body);
		contr.appendChild(table_prices);
		
		//Plashtane na 3 vnoski
		
		var table_prices=document.createElement("table");
		table_prices.setAttribute('id','GOT3');
		table_prices.style.display="none";
		table_prices.setAttribute("cellPadding", "0");
		table_prices.setAttribute("cellSpacing", "0");
		var table_head=document.createElement("thead");
		table_prices.appendChild(table_head);	
		var table_body=document.createElement("tbody");	
		for (i=0; i<cnt; i++){
			if(parseInt(JSONData.ResultSet.Result[i].price_d_3)>0){
				//izpisvane imeto na companiyata
				var td= document.createElement("td");
				var t=document.createTextNode(JSONData.ResultSet.Result[i].CompanyName);
				td.appendChild(t);
				//td.setAttribute('colSpan','5');
				td.setAttribute('class','td_company_name');
				td.setAttribute('className','td_company_name');
				var  tr= document.createElement("tr");
				if(i==0){
					tr.setAttribute('class','top_oferta');
					tr.setAttribute('className','top_oferta');
				}
				tr.appendChild(td);
				for(j=0;j<th_3.length;j++){
					var td=document.createElement("td");
					var t=document.createTextNode(th_3[j]);
					td.appendChild(t);
					td.setAttribute('class','td_pp');
					td.setAttribute('className','td_pp');
					tr.appendChild(td);
				};
				var td=document.createElement("td");
				td.setAttribute('class','td_pi');
				td.setAttribute('className','td_pi');
				tr.appendChild(td);
				table_body.appendChild(tr);
				
				var  tr= document.createElement("tr");
				if(i==0){
					tr.setAttribute('class','top_oferta');
					tr.setAttribute('className','top_oferta');
				}
				var  td= document.createElement("td");
				var img=document.createElement("img");
				img.src='http://www.getins.bg/images/loga/'+JSONData.ResultSet.Result[i].logo;
				td.appendChild(img);
				td.setAttribute('class','td_logo');
				td.setAttribute('className','td_logo');
				tr.appendChild(td);	
				
				
				var  td= document.createElement("td");
				var t=document.createTextNode(JSONData.ResultSet.Result[i].price_d_3_1+" лв.");
				td.appendChild(t);
				tr.appendChild(td);
				td.setAttribute('class','vn1');
				td.setAttribute('className','vn1');
				var  td= document.createElement("td");
				var t=document.createTextNode(JSONData.ResultSet.Result[i].price_d_3_2+" лв.");
				td.appendChild(t);
				tr.appendChild(td);
				td.setAttribute('class','vn1');
				td.setAttribute('className','vn1');
				var  td= document.createElement("td");
				var t=document.createTextNode(JSONData.ResultSet.Result[i].price_d_3_2+" лв.");
				td.appendChild(t);
				tr.appendChild(td);
				td.setAttribute('class','vn1');
				td.setAttribute('className','vn1');
				var  td= document.createElement("td");
				var t=document.createTextNode(JSONData.ResultSet.Result[i].price_d_3+" лв.");
				td.appendChild(t);
				tr.appendChild(td);
				td.setAttribute('class','vn1');
				td.setAttribute('className','vn1');
				
				var  td= document.createElement("td");
				td.setAttribute('class','vn3');
				td.setAttribute('className','vn3');
				if(JSONData.ResultSet.Result[i].price_d_3==0){
					var t=document.createTextNode("Не се предлага");
					td.appendChild(t);
				}else{
					var  button= document.createElement("button");
				var  button= document.createElement("input");
			//var t=document.createTextNode("ЗАЯВКА ЗА ПОЛИЦА");
			//button.appendChild(t);
			button.setAttribute('type', 'image');
			button.src= 'images1/bay.png';
					button.setAttribute('id', 'but_'+JSONData.ResultSet.Result[i].Id+'_3');
					addEvent(button, 'click', choise_copmany_price, false);
					td.appendChild(button);
				}
				tr.appendChild(td);
				td.setAttribute('class','vn3');
				td.setAttribute('className','vn3');
				
				table_body.appendChild(tr);
				var  tr= document.createElement("tr");
				if(i==0){
					tr.setAttribute('class','top_oferta');
					tr.setAttribute('className','top_oferta');
				}
				var  td= document.createElement("td");
				td.innerHTML=JSONData.ResultSet.Result[i].descr;
				td.setAttribute('class','infoprice');
				td.setAttribute('className','infoprice');
				td.setAttribute('colSpan','6');
				tr.appendChild(td);
				table_body.appendChild(tr);
				
				var  tr= document.createElement("tr");
				var  td= document.createElement("td");
				td.setAttribute('class','trDel');
				td.setAttribute('className','trDel');
				td.setAttribute('colSpan','6');
				tr.appendChild(td);
				table_body.appendChild(tr);
			}
		}		
		table_prices.appendChild(table_body);
		contr.appendChild(table_prices);
		
		
		//Plashtane na 4 vnoski
		
		var table_prices=document.createElement("table");
		table_prices.setAttribute('id','GOT4');
		table_prices.style.display="none";
		table_prices.setAttribute("cellPadding", "0");
		table_prices.setAttribute("cellSpacing", "0");
		var table_head=document.createElement("thead");
		table_prices.appendChild(table_head);	
		var table_body=document.createElement("tbody");	
		for (i=0; i<cnt; i++){	
			if(parseInt(JSONData.ResultSet.Result[i].price_d_4)>0){
				//izpisvane imeto na companiyata
				var td= document.createElement("td");
				var t=document.createTextNode(JSONData.ResultSet.Result[i].CompanyName);
				td.appendChild(t);
				td.setAttribute('class','td_company_name');
				td.setAttribute('className','td_company_name');
				var  tr= document.createElement("tr");
				tr.appendChild(td);
				for(j=0;j<th_4.length;j++){
					var td=document.createElement("td");
					var t=document.createTextNode(th_4[j]);
					td.appendChild(t);
					td.setAttribute('class','td_pp');
					td.setAttribute('className','td_pp');
					tr.appendChild(td);
				};
				var td=document.createElement("td");
				td.setAttribute('class','td_pi');
				td.setAttribute('className','td_pi');
				
				tr.appendChild(td);
				if(i==0){
					tr.setAttribute('class','top_oferta');
					tr.setAttribute('className','top_oferta');
				}
				table_body.appendChild(tr);
				
				var  tr= document.createElement("tr");
				if(i==0){
					tr.setAttribute('class','top_oferta');
					tr.setAttribute('className','top_oferta');
				}
				var  td= document.createElement("td");
				var img=document.createElement("img");
				img.src='http://www.getins.bg/images/loga/'+JSONData.ResultSet.Result[i].logo;
				td.appendChild(img);
				td.setAttribute('class','td_logo');
				td.setAttribute('className','td_logo');
				tr.appendChild(td);	
				var  td= document.createElement("td");
				var t=document.createTextNode(JSONData.ResultSet.Result[i].price_d_4_1+" лв.");
				td.appendChild(t);
				tr.appendChild(td);
				td.setAttribute('class','vn1');
				td.setAttribute('className','vn1');
				var  td= document.createElement("td");
				var t=document.createTextNode(JSONData.ResultSet.Result[i].price_d_4_2+" лв.");
				td.appendChild(t);
				tr.appendChild(td);
				td.setAttribute('class','vn1');
				td.setAttribute('className','vn1');
				var  td= document.createElement("td");
				var t=document.createTextNode(JSONData.ResultSet.Result[i].price_d_4_2+" лв.");
				td.appendChild(t);
				tr.appendChild(td);
				td.setAttribute('class','vn1');
				td.setAttribute('className','vn1');	
				var  td= document.createElement("td");
				var t=document.createTextNode(JSONData.ResultSet.Result[i].price_d_4_2+" лв.");
				td.appendChild(t);
				tr.appendChild(td);
				td.setAttribute('class','vn1');
				td.setAttribute('className','vn1');				
				var  td= document.createElement("td");
				var t=document.createTextNode(JSONData.ResultSet.Result[i].price_d_4+" лв.");
				td.appendChild(t);
				tr.appendChild(td);
				td.setAttribute('class','vn1');
				td.setAttribute('className','vn1');
				
				var  td= document.createElement("td");
				if(JSONData.ResultSet.Result[i].price_d_4==0){
					var t=document.createTextNode("Не се предлага");
					td.appendChild(t);
				}else{
					var  button= document.createElement("button");
					var  button= document.createElement("input");
			//var t=document.createTextNode("ЗАЯВКА ЗА ПОЛИЦА");
			//button.appendChild(t);
			button.setAttribute('type', 'image');
			button.src= 'images1/bay.png';
					button.setAttribute('id', 'but_'+JSONData.ResultSet.Result[i].Id+'_4');
					addEvent(button, 'click', choise_copmany_price, false);
					td.appendChild(button);
				}
				tr.appendChild(td);
				td.setAttribute('class','vn3');
				td.setAttribute('className','vn3');
				table_body.appendChild(tr);
				var  tr= document.createElement("tr");
				if(i==0){
					tr.setAttribute('class','top_oferta');
					tr.setAttribute('className','top_oferta');
				}
				var  td= document.createElement("td");
				td.innerHTML=JSONData.ResultSet.Result[i].descr;
				td.setAttribute('class','infoprice');
				td.setAttribute('className','infoprice');
				td.setAttribute('colSpan','7');
				tr.appendChild(td);
				table_body.appendChild(tr);
				
				var  tr= document.createElement("tr");
				var  td= document.createElement("td");
				td.setAttribute('class','trDel');
				td.setAttribute('className','trDel');
				td.setAttribute('colSpan','7');
				tr.appendChild(td);
				table_body.appendChild(tr);
			}
		}		
		table_prices.appendChild(table_body);
		contr.appendChild(table_prices);
		//document.getElementById("transparent").style.display="";
		document.getElementById("view_price_cont").style.display="";
		document.getElementById("view_price_container").style.display='';
		
		document.getElementById("table_actualni_ceni").style.display='';
		
    }
}

function close_price_list(){
	document.getElementById("view_price_cont").style.display="none";
	try{document.getElementById("view_contact_details").style.display="none";}catch(err){}
	try{document.getElementById("view_owner_details").style.display="none";}catch(err){}
	try{document.getElementById("view_driver_details").style.display="none";}catch(err){}
	try{document.getElementById("view_mps_details").style.display="none";}catch(err){}
	try{document.getElementById("view_thank_page").style.display="none";}catch(err){}
	document.getElementById("transparent").style.display="none";
	document.getElementById("central_part").style.display="";

}

function viewPriceKasko(JSONData) {
	 if (JSONData != null){
		contr_id='view_price_container';
		var contr=document.getElementById(contr_id);
		contr.innerHTML='';
		cnt=1*JSONData.ResultSet.totalResultsReturned;
		var table_prices=document.createElement("table");
		table_prices.setAttribute('cellspacing','0');
		table_prices.setAttribute('cellpadding','0');
		var table_head=document.createElement("thead");
		table_prices.appendChild(table_head);	
		var table_body=document.createElement("tbody");	
		table_body.setAttribute('id','payment1');		
		for (i=0; i<cnt; i++){
			
			//izpisvane imeto na companiyata
			var td= document.createElement("td");
			var t=document.createTextNode(JSONData.ResultSet.Result[i].CompanyName);
		  	td.appendChild(t);
			td.setAttribute('class','td_company_name');
			td.setAttribute('className','td_company_name');
			var  tr= document.createElement("tr");
			tr.appendChild(td);
			var  td= document.createElement("td");
			td.setAttribute('class','td_antet');
			td.setAttribute('className','td_antet');
			var t=document.createTextNode('Цена в Комапнията');
			//td.setAttribute('colSpan','2');
			td.appendChild(t);
			tr.appendChild(td);
			var  td= document.createElement("td");
			td.setAttribute('class','td_antet');
			td.setAttribute('className','td_antet');
			var t=document.createTextNode('Отстъпка');
			//td.setAttribute('colSpan','2');
			td.appendChild(t);
			tr.appendChild(td);
			var  td= document.createElement("td");
			td.setAttribute('class','td_antet');
			td.setAttribute('className','td_antet');
			var t=document.createTextNode('Крайна Цена');
			//td.setAttribute('colSpan','2');
			td.appendChild(t);
			tr.appendChild(td);
			var  td= document.createElement("td");
			td.setAttribute('class','td_antet');
			td.setAttribute('className','td_antet');
			var t=document.createTextNode('Еднократно плащане');
			//td.setAttribute('colSpan','2');
			td.appendChild(t);
			tr.appendChild(td);
			table_body.appendChild(tr);
			
			var  tr= document.createElement("tr");
			tr.setAttribute('valign','top');
			var  td= document.createElement("td");
			var img=document.createElement("img");
			//img.src='http://www.getins.bg/images/loga/'+JSONData.ResultSet.Result[i].logo;
			//td.appendChild(img);
			td.setAttribute('class','td_logo');
			td.setAttribute('className','td_logo');	
			var pn=document.createTextNode(JSONData.ResultSet.Result[i].productName);
			td.innerHTML="<h3>"+JSONData.ResultSet.Result[i].productName+"</h3>";	
			var img=document.createElement("img");
			img.src='http://www.getins.bg/images/loga/'+JSONData.ResultSet.Result[i].logo;
			td.appendChild(img);
			tr.appendChild(td);
			var  td= document.createElement("td");
			td.setAttribute('class','price_company');
			td.setAttribute('className','price_company');
			//div.setAttribute('class','price');
			//div.setAttribute('className','price');
			td.innerHTML=JSONData.ResultSet.Result[i].price1;
			tr.appendChild(td);
			var  td= document.createElement("td");
			td.setAttribute('class','price_company');
			td.setAttribute('className','price_company');
			td.innerHTML=JSONData.ResultSet.Result[i].discount1;
			tr.appendChild(td);
			var  td= document.createElement("td");
			td.setAttribute('class','price_company');
			td.setAttribute('className','price_company');
			td.innerHTML=JSONData.ResultSet.Result[i].price11;
			tr.appendChild(td);
			var  td= document.createElement("td");
			var  button= document.createElement("button");
			var t=document.createTextNode("Заявка за подробна оферта");
			button.appendChild(t);
			button.appendChild(t);
			button.setAttribute('id', 'but_'+JSONData.ResultSet.Result[i].Id+'_1');
			td.appendChild(button);			
			tr.appendChild(td);
			addEvent(button, 'click', choise_copmany_price_kasko, false);
			//ime na kompaniyata
			table_body.appendChild(tr);
		}
		
		table_prices.appendChild(table_body);
		var table_body=document.createElement("tbody");	
		table_body.setAttribute('id','payment2');	
		table_body.style.display='none';
		for (i=0; i<cnt; i++){
			
			//alert(JSONData.ResultSet.Result[i].price2);
			if(JSONData.ResultSet.Result[i].price2 != '<b>0 лв. </b>'){
				//izpisvane imeto na companiyata
				var td= document.createElement("td");
				var t=document.createTextNode(JSONData.ResultSet.Result[i].CompanyName);
			  	td.appendChild(t);
				td.setAttribute('class','td_company_name');
				td.setAttribute('className','td_company_name');
				var  tr= document.createElement("tr");
				tr.appendChild(td);
				var  td= document.createElement("td");
				td.setAttribute('class','td_antet');
				td.setAttribute('className','td_antet');
				var t=document.createTextNode('Цена в Комапнията');
				//td.setAttribute('colSpan','2');
				td.appendChild(t);
				tr.appendChild(td);
				var  td= document.createElement("td");
				td.setAttribute('class','td_antet');
				td.setAttribute('className','td_antet');
				var t=document.createTextNode('Отстъпка');
				//td.setAttribute('colSpan','2');
				td.appendChild(t);
				tr.appendChild(td);
				var  td= document.createElement("td");
				td.setAttribute('class','td_antet');
				td.setAttribute('className','td_antet');
				var t=document.createTextNode('Крайна Цена');
				//td.setAttribute('colSpan','2');
				td.appendChild(t);
				tr.appendChild(td);
				var  td= document.createElement("td");
				td.setAttribute('class','td_antet');
				td.setAttribute('className','td_antet');
				var t=document.createTextNode('Плащане на вноски');
				//td.setAttribute('colSpan','2');
				td.appendChild(t);
				tr.appendChild(td);
				table_body.appendChild(tr);
				
				var  tr= document.createElement("tr");
				tr.setAttribute('valign','top');
				var  td= document.createElement("td");
				
				td.setAttribute('class','td_logo');
				td.setAttribute('className','td_logo');
				var pn=document.createTextNode(JSONData.ResultSet.Result[i].productName);
				td.innerHTML="<h3>"+JSONData.ResultSet.Result[i].productName+"</h3>";	
				var img=document.createElement("img");
				img.src='http://www.getins.bg/images/loga/'+JSONData.ResultSet.Result[i].logo;
				td.appendChild(img);
				tr.appendChild(td);
				var  td= document.createElement("td");
				td.setAttribute('class','price_company');
				td.setAttribute('className','price_company');
				//div.setAttribute('class','price');
				//div.setAttribute('className','price');
				td.innerHTML=JSONData.ResultSet.Result[i].price2;
				tr.appendChild(td);
				var  td= document.createElement("td");
				td.setAttribute('class','price_company');
				td.setAttribute('className','price_company');
				td.innerHTML=JSONData.ResultSet.Result[i].discount2;
				tr.appendChild(td);
				var  td= document.createElement("td");
				td.setAttribute('class','price_company');
				td.setAttribute('className','price_company');
				td.innerHTML=JSONData.ResultSet.Result[i].price21;
				tr.appendChild(td);
				var  td= document.createElement("td");
				var  button= document.createElement("button");
				var t=document.createTextNode("Заявка за подробна оферта");
				button.appendChild(t);
				button.appendChild(t);
				button.setAttribute('id', 'but_'+JSONData.ResultSet.Result[i].Id+'_2');
				td.appendChild(button);			
				tr.appendChild(td);
				addEvent(button, 'click', choise_copmany_price_kasko, false);
				//ime na kompaniyata
				table_body.appendChild(tr);
			}
		}
		
		table_prices.appendChild(table_body);
		
		contr.appendChild(table_prices);
		//document.getElementById("transparent").style.display="";
		document.getElementById("transparent").style.display="";
		//document.getElementById("transparent").style.height="100%";
		document.getElementById("view_price_cont").style.display="";
		document.getElementById("view_price_container").style.display='';
		document.getElementById("contacts_details_form").style.display='none';
		
		document.getElementById("table_actualni_ceni").style.display='';
		//document.getElementById("table_cont_details").style.display='none';
		//document.getElementById("view_price_head").style.width='958px';
		document.getElementById("fields_holder").style.display='none';
		
    }
}

function view_kasko2(){
	document.getElementById('payment1').style.display='none';
	document.getElementById('payment2').style.display='';
	document.getElementById('bp1').className='p2';
	document.getElementById('bp2').className='p1';
}

function view_kasko1(){
	document.getElementById('payment2').style.display='none';
	document.getElementById('payment1').style.display='';
	document.getElementById('bp1').className='p1';
	document.getElementById('bp2').className='p2';
}

function changeTypeMPS(val){
	switch (val){
	case '1'://leki konski_sili
		document.getElementById('konski_sili').value='0';
		document.getElementById('tovaronosimost_rem').value='0';
		document.getElementById('tovaronosimost').value='0';
		document.getElementById('masa').value='0';
		document.getElementById('kubatura_mtp').value='0';
		document.getElementById('mesta_bus').value='0';
		//alert(document.getElementById('tovaronosimost').value);
	break;
	case '2': //tovaren
		document.getElementById('konski_sili').value='0';
		document.getElementById('kubatura').value='0';
		document.getElementById('owner_old').value='0';
		document.getElementById('mesta_bus').value='0';
		document.getElementById('kubatura_mtp').value='0';
		document.getElementById('tovaronosimost_rem').value='0';
	break;
	case '3'://motoped
		document.getElementById('kubatura').value='0';
		document.getElementById('owner_old').value='0';
		document.getElementById('mesta_bus').value='0';
		document.getElementById('tovaronosimost').value='0';
		document.getElementById('masa').value='0';
		document.getElementById('tovaronosimost_rem').value='0';
		document.getElementById('konski_sili').value='0';
	break;
	case '4'://motociklet
		document.getElementById('kubatura').value='0';
		document.getElementById('owner_old').value='0';
		document.getElementById('mesta_bus').value='0';
		document.getElementById('tovaronosimost').value='0';
		document.getElementById('masa').value='0';
		document.getElementById('tovaronosimost_rem').value='0';
		document.getElementById('konski_sili').value='0';
	break;
	case '7'://tovarno remarke
		document.getElementById('kubatura').value='0';
		document.getElementById('owner_old').value='0';
		document.getElementById('mesta_bus').value='0';
		document.getElementById('kubatura_mtp').value='0';
		document.getElementById('tovaronosimost').value='0';
		document.getElementById('masa').value='0';
		document.getElementById('konski_sili').value='0';
	break;
	case '8'://vleka4
		document.getElementById('kubatura').value='0';
		document.getElementById('owner_old').value='0';
		document.getElementById('mesta_bus').value='0';
		document.getElementById('kubatura_mtp').value='0';
		document.getElementById('tovaronosimost').value='0';
		document.getElementById('masa').value='0';
		document.getElementById('tovaronosimost_rem').value='0';
		document.getElementById('konski_sili').value='';
	break;
	case '9'://avtobus
		document.getElementById('kubatura').value='0';
		document.getElementById('owner_old').value='0';
		document.getElementById('kubatura_mtp').value='0';
		document.getElementById('tovaronosimost').value='0';
		document.getElementById('masa').value='0';
		document.getElementById('tovaronosimost_rem').value='0';
		document.getElementById('konski_sili').value='0';
	break;
	case '17'://traktor
		document.getElementById('kubatura').value='0';
		document.getElementById('owner_old').value='0';
		document.getElementById('mesta_bus').value='0';
		document.getElementById('kubatura_mtp').value='0';
		document.getElementById('tovaronosimost').value='0';
		document.getElementById('masa').value='0';
		document.getElementById('tovaronosimost_rem').value='0';
		document.getElementById('konski_sili').value='0';
	break;
	}
}
function changeTypeOT(val){
	if(val==2){
		document.getElementById('owner_old').value='0';
	}
}

function setDateField(id, val){
	var dat=val.split(".");
	document.getElementById(id).value=dat[2]+"_"+dat[1]+"_"+dat[0];
}

