// Submit kontakt formular ***********************************************************************************

function subcalc(obj) {
  with(document.online) {
    if (obj.value == "") {
      cc = 0;
    }
    else cc = parseInt(obj.value);
    if (isNaN(cc)) {
      window.alert("Please enter only numbers.");
      obj.focus();
      return 0;
    }
    else return cc;
  }
}

function calc() {
  var c;
  with(document.online) {
    c = 0;
    //Boxes
    c = c + subcalc(bo_book) * 1.5;
    c = c + subcalc(bo_linen_small) * 3.1;
    c = c + subcalc(bo_linen_large) * 4.5;
    c = c + subcalc(bo_china_dish) * 10;
    c = c + subcalc(bo_picture) * 3;
    c = c + subcalc(bo_tv_large) * 6;
    c = c + subcalc(bo_tv_small) * 6;
    c = c + subcalc(bo_wardrobe) * 15;
    c = c + subcalc(bo_file) * 2.5;

    //Furniture - Living Room
    c = c + subcalc(li_bar_portable) * 15
    c = c + subcalc(li_bench) * 5;
    c = c + subcalc(li_bookcase) * 20;
    c = c + subcalc(li_bookshelves_sectional) * 5;
    c = c + subcalc(li_chair_arm) * 10; 
    c = c + subcalc(li_chair_occasional) * 15;
    c = c + subcalc(li_chair_overstuffed) * 25;
    c = c + subcalc(li_chair_rocker) * 12;
    c = c + subcalc(li_chair_straight) * 5;
    c = c + subcalc(li_chair_grandfather) * 20;
    c = c + subcalc(li_day_bed) * 30;       
    c = c + subcalc(li_desk_small) * 22;
    c = c + subcalc(li_desk_secretary) * 35;
    c = c + subcalc(li_fireplace_equipment) * 5;
    c = c + subcalc(li_foot_stool) * 2;
    c = c + subcalc(li_lamp_floor) * 3;
    c = c + subcalc(li_magazine_rack) * 2;
    c = c + subcalc(li_music_cabinet) * 10;
    c = c + subcalc(li_piano_baby) * 70;
    c = c + subcalc(li_piano_gr) * 70;
    c = c + subcalc(li_piano_upright) * 70;
    c = c + subcalc(li_piano_parlor_grand) * 80;
    c = c + subcalc(li_piano_spinet) * 60;  
    c = c + subcalc(li_radio_table) * 2;
    c = c + subcalc(li_record_player) * 2;
    c = c + subcalc(li_rugs_large_roll) * 10;
    c = c + subcalc(li_rugs_small_roll) * 6;
    c = c + subcalc(li_sofa_2cushions) * 35;
    c = c + subcalc(li_sofa_3cushions) * 50;
    c = c + subcalc(li_sofa_4cushions) * 60;
    c = c + subcalc(li_sofa_sectional) * 30;
    c = c + subcalc(li_stereo_component) * 8;
    c = c + subcalc(li_stud_couch) * 50;
    c = c + subcalc(li_tables_dropl) * 12;
    c = c + subcalc(li_tables_cofee) * 5;
    c = c + subcalc(li_telephone_stand) * 5;
    c = c + subcalc(li_television_big) * 40;
    c = c + subcalc(li_television_combination) * 25;
    c = c + subcalc(li_tv_radio_console) * 15;
    c = c + subcalc(li_television_table_model) * 10;
    
    //Dining Room
    c = c + subcalc(di_bench_harvest) * 10;
    c = c + subcalc(di_buffet) * 30;
    c = c + subcalc(di_cabinet_corner) * 20;
    c = c + subcalc(di_cabinet_china) * 25;
    c = c + subcalc(di_chair_dining) * 5;
    c = c + subcalc(di_server) * 15;
    c = c + subcalc(di_table_dining) * 30;
    c = c + subcalc(di_tea_cart) * 10;
    c = c + subcalc(di_rugs_large) * 10;
    c = c + subcalc(di_rugs_small) * 3;
    
    //Bedroom
    c = c + subcalc(be_bed_double) * 60;
    c = c + subcalc(be_bed_kingsize) * 70;
    c = c + subcalc(be_bed_single) * 40;
    c = c + subcalc(be_bed_rollaway) * 20;
    c = c + subcalc(be_bed_bunk) * 70;
    c = c + subcalc(be_bookshelves_sectional) * 5;
    c = c + subcalc(be_bureau) * 25;
    c = c + subcalc(be_dresser_single) * 25;
    c = c + subcalc(be_dresser_double) * 50;
    c = c + subcalc(be_dresser_triple) * 75;
    c = c + subcalc(be_chest) * 30;
    c = c + subcalc(be_chair_boudoir) * 10;
    c = c + subcalc(be_chair_straight) * 5; 
    c = c + subcalc(be_chaise_lounge) * 25;
    c = c + subcalc(be_desk_small) * 22;
    c = c + subcalc(be_dresser_vanity_bench) * 3; 
    c = c + subcalc(be_night_table) * 5; 
    c = c + subcalc(be_rug_large) * 10;
    c = c + subcalc(be_rug_small) * 6; 
    c = c + subcalc(be_vanity_dresser) * 20;
    c = c + subcalc(be_wardrobe_small) * 20;
    c = c + subcalc(be_wardrobe_large) * 40;
    
    //Nursery
    c = c + subcalc(nu_bathinette) * 5;
    c = c + subcalc(nu_bed_youth) * 30;
    c = c + subcalc(nu_chair_childs) * 3;
    c = c + subcalc(nu_chair_high) * 5;
    c = c + subcalc(nu_chest) * 12;
    c = c + subcalc(nu_chest_toy) * 5;
    c = c + subcalc(nu_crib_baby) * 10;
    c = c + subcalc(nu_table_child) * 5;
    c = c + subcalc(nu_playpen) * 10;
    c = c + subcalc(nu_rug_large) * 10;
    c = c + subcalc(nu_rug_small) * 6;

    //Kitchen
    c = c + subcalc(ki_breakfast_suit_chairs) * 5;
    c = c + subcalc(ki_breakfast_table) * 10;
    c = c + subcalc(ki_chair_high) * 5;
    c = c + subcalc(ki_kitchen_cabinet) * 30;
    c = c + subcalc(ki_roaster) * 5;
    c = c + subcalc(ki_microwave) * 10;
    c = c + subcalc(ki_toaster_oven) * 10;
    c = c + subcalc(ki_serving_cart) * 15;
    c = c + subcalc(ki_stoll) * 3;
    c = c + subcalc(ki_table) * 5;
    c = c + subcalc(ki_utility_cabinet) * 10;
    c = c + subcalc(ki_vegetable_bin) * 3;

    //Appliances
    c = c + subcalc(ap_air_conditioner_window) * 30;
    c = c + subcalc(ap_dehumidifier) * 10;
    c = c + subcalc(ap_dishwasher) * 20;
    c = c + subcalc(ap_dryer) * 25;

    //Freezer (CU Capacity)
    c = c + subcalc(fr_10_or_less) * 30;
    c = c + subcalc(fr_11_to_15) * 45;
    c = c + subcalc(fr_16_and_over) * 60;
    c = c + subcalc(fr_ironer) * 12;
    c = c + subcalc(fr_range) * 30;

    //Refrigerator (CU Capacity)
    c = c + subcalc(re_6_or_less) * 30;
    c = c + subcalc(re_7_to_10) * 45;
    c = c + subcalc(re_11_and_over) * 60;
    c = c + subcalc(re_vacuum_cleaner) * 5;
    c = c + subcalc(re_washing_machine) * 25;

    //Porch & Outdoor
    c = c + subcalc(po_barbecue) * 10;
    c = c + subcalc(po_bath_bird) * 5;
    c = c + subcalc(po_chairs_lawn) * 5;
    c = c + subcalc(po_chairs_porch) * 10;
    c = c + subcalc(po_clothes_dryer_rack) * 5;
    c = c + subcalc(po_garden_hose) * 10;
    c = c + subcalc(po_ladder_extension) * 10;
    c = c + subcalc(po_lawn_mower_hand) * 5;
    c = c + subcalc(po_lawn_mower_power) * 15;
    c = c + subcalc(po_lawn_mower_riding) * 35;
    c = c + subcalc(po_leaf_sweeper) * 5;
    c = c + subcalc(po_outdoor_childs_slide) * 10;
    c = c + subcalc(po_outdoor_childs_gym) * 20;
    c = c + subcalc(po_outdoor_childs_racks) * 5;
    c = c + subcalc(po_outdoor_swings) * 30;
    c = c + subcalc(po_picnic_table) * 20;
    c = c + subcalc(po_porch_chair) * 10;
    c = c + subcalc(po_rocker_swing) * 10;
    c = c + subcalc(po_roller_lawn) * 15;
    c = c + subcalc(po_rug_large) * 10;
    c = c + subcalc(po_rug_small) * 6;
    c = c + subcalc(po_sand_box) * 10;
    c = c + subcalc(po_spreader) * 1;
    c = c + subcalc(po_table) * 10;
    c = c + subcalc(po_umbrella) * 5;
    c = c + subcalc(po_wheelbarrow) * 8;
    
    //Miscellaneous
    c = c + subcalc(mi_trash_can) * 7;
    c = c + subcalc(mi_basket_clothes) * 5;
    c = c + subcalc(mi_bicycle) * 10;
    c = c + subcalc(mi_bird_cage) * 5;
    c = c + subcalc(mi_card_table) * 3;
    c = c + subcalc(mi_cabinet_filling) * 20;
    c = c + subcalc(mi_carriage_baby) * 20;
    c = c + subcalc(mi_chairs_folding) * 1;
    c = c + subcalc(mi_clothes_hamper) * 5;
    c = c + subcalc(mi_cot_folding) * 10;
    c = c + subcalc(mi_desk_office) * 30;
    c = c + subcalc(mi_fan) * 5;
    c = c + subcalc(mi_fernery) * 10;
    c = c + subcalc(mi_foot_lockers) * 5;
    c = c + subcalc(mi_golf_bag) * 2;
    c = c + subcalc(mi_heater_gas_small) * 5;
    c = c + subcalc(mi_metal_shelves_each) * 2;
    c = c + subcalc(mi_pc_tower) * 4;
    c = c + subcalc(mi_pc_monitor) * 4;
    c = c + subcalc(mi_printer) * 3;
    c = c + subcalc(mi_ping_pong_table) * 20;
    c = c + subcalc(mi_pool_table_small) * 40;
    c = c + subcalc(mi_power_tools) * 20;
    c = c + subcalc(mi_sewing_machine) * 10;
    c = c + subcalc(mi_sled) * 2;
    c = c + subcalc(mi_step_ladder) * 5;
    c = c + subcalc(mi_suitcase) * 5;
    c = c + subcalc(mi_table_utility) * 5;
    c = c + subcalc(mi_tackle_box) * 1;
    c = c + subcalc(mi_tool_box) * 10;
    c = c + subcalc(mi_wagon_childs) * 5;
    c = c + subcalc(mi_work_bench) * 20;
    
//    cf_t.value = c; // temporary calc
    cf.value = c;
  } 
    
}   
    
function submitF1(obj) {
  if (ValidateF1(obj)) {
    calc();
    return true;
  }
  else return false;
}

function submitF4(obj) {
  if (ValidateF4(obj)) return true;
  else return false;
}

function submitS1(obj) {
  if (ValidateS1(obj)) return true;
  else return false;
}

function submitS2(obj) {
  if (ValidateS2(obj)) return true;
  else return false;
}

function ValidateF1(obj) {
  var pz = 3; // min. pocet znaku
  with(obj) {
    if (your_name.value.length < pz){
      window.alert("Please enter your 'Name'.");
      your_name.focus();
      return false;		
    }
    if (!isValidEmail(email.value)){
      window.alert("Please enter your email address in the form of name@domain.com");
      email.focus();
      return false;     	
    }
    if (phone.value.length < pz){
      window.alert("Please enter your 'Phone'.");
      phone.focus();
      return false;		
    }
  }
  return true;
}

function ValidateF4(obj) {
  var pz = 3; // min. pocet znaku
  with(obj) {
    if (business_name.value.length < pz){
      window.alert("Please enter your 'Business Name'.");
      business_name.focus();
      return false;		
    }
    if (contact_person.value.length < pz){
      window.alert("Please enter your 'Contact Person'.");
      contact_person.focus();
      return false;		
    }
    if (!isValidEmail(email.value)){
      window.alert("Please enter your email address in the form of name@domain.com");
      email.focus();
      return false;     	
    }
    if (phone.value.length < pz){
      window.alert("Please enter your 'Phone'.");
      phone.focus();
      return false;		
    }
  }
  return true;
}

function ValidateS1(obj) {
  var pz = 3; // min. pocet znaku
  with(obj) {
    if (name.value.length < pz){
      window.alert("Please enter your 'Name'.");
      name.focus();
      return false;		
    }
    if (!isValidEmail(email.value)){
      window.alert("Please enter your email address in the form of name@domain.com");
      email.focus();
      return false;     	
    }
  }
  return true;
}

function ValidateS2(obj) {
  var pz = 3; // min. pocet znaku
  with(obj) {
    if (your_name.value.length < pz){
      window.alert("Please enter your 'Name'.");
      your_name.focus();
      return false;		
    }
    if (!isValidEmail(email.value)){
      window.alert("Please enter your email address in the form of name@domain.com");
      email.focus();
      return false;     	
    }
  }
  return true;
}

function isValidEmail(Email) {
  if (Email.length<4) return false;
  else if (Email.lastIndexOf(' ')!=-1) return false;
  else if (Email.lastIndexOf('\'')!=-1) return false;
  else if ((i=Email.lastIndexOf('@'))==-1) return false;
  else {
    var tail=Email.substring(i+1,Email.length);
    if (tail.length<3) return false;
    else if ((i = tail.lastIndexOf('.'))==-1) return false;
    else {
      var tailend=tail.substring(i+1,tail.length);
      if (tailend.length==0) return false;
    }
  }
  return true;
}

// Submit kontakt formular ***********************************************************************************

function MM_openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  ww = window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
  ww.focus();
}

// funkce zjisti prohlizec IE v4.0 a vyssi -> spusti FLASH stranku pokud je nainstalovan FLASH plugin
// nevyhovuje-li: spusti stranku bez FLASHE
function MM_checkPlugin(plgIn, theURL, altURL, autoGo) { //v4.0
  var ok=false; document.MM_returnValue = false;
  var verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr);
  IEvers="4.0";
  if (app.indexOf('Microsoft') != -1) {
    if (version >= IEvers || verStr.indexOf(IEvers) != -1) {

      with (navigator) if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
        ok=(plugins && plugins[plgIn]);
      } else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
        if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
        else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
        else ok=autoGo; }
      if (!ok) theURL=altURL;
    }
  } else theURL=altURL;
  
  if (theURL) window.location=theURL;
}

function OnSubmit(obj) {
  with(obj) {
    submit();
  }
}

// begin absolutely positioned scrollable area object scripts 
// Extension developed by David G. Miles 
// Original Scrollable Area code developed by Thomas Brattli 
function verifyCompatibleBrowser(){ 
    this.ver=navigator.appVersion 
    this.dom=document.getElementById?1:0 
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
    this.ie4=(document.all && !this.dom)?1:0; 
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
 
    this.ns4=(document.layers && !this.dom)?1:0; 
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
    return this 
} 
bw=new verifyCompatibleBrowser() 
 
 
var speed=50 
 
var loop, timer 
 
function ConstructObject(obj,nest){ 
    nest=(!nest) ? '':'document.'+nest+'.' 
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight 
    this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight 
    this.up=MoveAreaUp;this.down=MoveAreaDown; 
    this.MoveArea=MoveArea; this.x; this.y; 
    this.obj = obj + "Object" 
    eval(this.obj + "=this") 
    return this 
} 
function MoveArea(x,y){ 
    this.x=x;this.y=y 
    this.css.left=this.x 
    this.css.top=this.y 
} 
 
function MoveAreaDown(move){ 
	if(this.y>-this.scrollHeight+objContainer.clipHeight){ 
    this.MoveArea(0,this.y-move) 
    if(loop) setTimeout(this.obj+".down("+move+")",speed) 
	} 
} 
function MoveAreaUp(move){ 
	if(this.y<0){ 
    this.MoveArea(0,this.y-move) 
    if(loop) setTimeout(this.obj+".up("+move+")",speed) 
	} 
} 
 
function PerformScroll(scrollobjekt, speed){ 
	if(initialised){ 
		loop=true; 
		if(speed>0) scrollobjekt.down(speed) 
		else scrollobjekt.up(speed) 
	} 
} 
 
function CeaseScroll(){ 
    loop=false 
    if(timer) clearTimeout(timer) 
} 
var initialised; 
function InitialiseScrollableArea(){ 
    objContainer=new ConstructObject('divContainer') 
    objScroller=new ConstructObject('divContent','divContainer') 
    objScroller.MoveArea(0,0) 
    objContainer.css.visibility='visible' 

//    objContainer2=new ConstructObject('divContainer2')
//    objScroller2=new ConstructObject('divContent2','divContainer2')
//    objScroller2.MoveArea(0,0)
//    objContainer2.css.visibility='visible'

    initialised=true; 
} 
// end absolutely positioned scrollable area object scripts 

function JustSoPicWindow(imageName,imageWidth,imageHeight,alt,bgcolor,hugger,hugMargin) {
// by E Michael Brandt of ValleyWebDesigns.com - Please leave these comments intact.
// version 3.0.4  

	if (bgcolor=="") {
		bgcolor="#FFFFFF";
	}
	var adj=10
	var w = screen.width;
	var h = screen.height;
	var byFactor=1;

	if(w<740){
	  var lift=0.90;
	}
	if(w>=740 & w<835){
	  var lift=0.91;
	}
	if(w>=835){
	  var lift=0.93;
	}
	if (imageWidth>w){	
	  byFactor = w / imageWidth;			
	  imageWidth = w;
	  imageHeight = imageHeight * byFactor;
	}
	if (imageHeight>h-adj){
	  byFactor = h / imageHeight;
	  imageWidth = (imageWidth * byFactor);
	  imageHeight = h; 
	}
	   
	var scrWidth = w-adj;
	var scrHeight = (h*lift)-adj;

	if (imageHeight>scrHeight){
  	  imageHeight=imageHeight*lift;
	  imageWidth=imageWidth*lift;
	}

	var posLeft=0;
	var posTop=0;

	if (hugger == "hug image"){
	  if (hugMargin == ""){
	    hugMargin = 0;
	  }
	  var scrHeightTemp = imageHeight - 0 + 2*hugMargin;
	  if (scrHeightTemp < scrHeight) {
		scrHeight = scrHeightTemp;
	  } 
	  var scrWidthTemp = imageWidth - 0 + 2*hugMargin;
	  if (scrWidthTemp < scrWidth) {
		scrWidth = scrWidthTemp;
	  }
	  
	  if (scrHeight<100){scrHeight=100;}
	  if (scrWidth<100){scrWidth=100;}

	  posTop =  ((h-(scrHeight/lift)-adj)/2);
	  posLeft = ((w-(scrWidth)-adj)/2);
 	}

	if (imageHeight > (h*lift)-adj || imageWidth > w-adj){
		imageHeight=imageHeight-adj;
		imageWidth=imageWidth-adj;
	}
	posTop = parseInt(posTop);
	posLeft = parseInt(posLeft);		
	scrWidth = parseInt(scrWidth); 
	scrHeight = parseInt(scrHeight);
	
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1){
	  var args= new Array();
	  args[0]='parent';
	  args[1]=imageName;
	  var i ; document.MM_returnValue = false;
	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	} else {
	newWindow = window.open("vwd_justso.htm","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+' onclick="self.close()">');  
	newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
	newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+' alt="kliknutím se okno zavře" >'); 
	newWindow.document.write('</td></tr></table></body></html>');
	newWindow.document.close();
	newWindow.focus();
	}
}

function Potvrd(akce, id, zazn) {
  text = "";
  if (!zazn) zazn = '...';
  if (id == "1") text = "Opravdu chcete záznam  ''" + zazn + "''  STORNOVAT?";
  if (id == "2") text = "Opravdu chcete záznam  ''" + zazn + "''  SMAZAT?";
  if (id == "3") text = "Opravdu chcete záznam  ''" + zazn + "''\nPŘESUNOUT do tiskových zpráv?";
  if (id == "4") text = "Opravdu chcete záznam  ''" + zazn + "''\nPŘESUNOUT zpět do aktualit?";
  if (confirm(text)) {
    location = akce;
  }
}

