// $Id: form_scripts.js 2727 2007-03-01 15:57:53Z zeke $
 

function handlerFunction(description,page,line) {
 // put error-handling operators here
 return true;
}
window.onerror=handlerFunction;



$(function() {
  
jQuery.fn.fixedCenter = function(){
	return this.each(function(){
		var element = jQuery(this);
		centerElement();
		jQuery(window).bind('resize',function(){
			centerElement();
		});
			
		function centerElement(){
			var elementWidth = jQuery(element).outerWidth();
			var elementHeight = jQuery(element).outerHeight();
			var windowWidth = jQuery(window).width();
			var windowHeight = jQuery(window).height();	
			
			var X2 = windowWidth/2 - elementWidth/2;
			var Y2 = windowHeight/2 - elementHeight/2;
	 
			jQuery(element).css({
				'left':X2,
				'top':Y2,
				'position':'fixed'
			});						
		} //end of centerElement function
					
	}); //end of return this.each
}
});  
  
  










$(document).ready(function() {




$('.shortlistadd').click(function() {
 $("#comparetop").show();
});
	
	 





$('#loader').fixedCenter();

$('form').bind('submit', function() {
    $('#loader').show().delay(2000).fadeOut('slow')
});

 $('.button, .schbutton, .rpclink, .imgcartbutton').click(function() {
 $('#loader').show().delay(2000).fadeOut('slow')
});
	



$("#accordion").accordion({
autoHeight: false
});

	
//$(function() {
///ajax add to cart in dialog
$("#ajax_message").dialog({
    title: 'Product added to basket',
    autoOpen: false,
    hide: 'clip',
    show: 'clip',
    //position:  ['right','top']
     width: 360
    });

$('#addtocart').click(function() { 
    $('#ajax_message').dialog('open');
//setTimeout($('#ajax_message').dialog("close"),5000);
});
///ajax add to cart in dialog


///jquery iframe
        $('a.iframepopup').click(function(e) {
            e.preventDefault();
            var $this = $(this);
            var horizontalPadding = 30;
            var verticalPadding = 30;
            $('<iframe id="externalSite" class="externalSite" src="' + this.href + '" />').dialog({
                title: ($this.attr('title')) ? $this.attr('title') : 'WatchShop.com',
                autoOpen: true,
                hide: 'fade',
                show: 'fade',
                width: 800,
                height: 500,
                modal: true,
                
                resizable: true,
                autoResize: true,
                
                overlay : { background: "#000", opacity: 0.1}

            }).width(800 - horizontalPadding).height(500 - verticalPadding);            
    });
});
///jquery iframe









function closethreedbutton() {


document.getElementById('zoom_display_overlay').style.display = 'none';
document.getElementById('zoom_display').style.display = 'none';

document.getElementById('closethreed').style.display = 'none';
document.getElementById('additionalimages').style.display = 'block';


if (document.getElementById('threedbutton')) {
 document.getElementById('threedbutton').style.display = 'block'; }

if (document.getElementById('flash3')) {
 document.getElementById('flash3').style.display = 'block'; }
 
 if (document.getElementById('flash2')) {
 document.getElementById('flash2').style.display = 'none'; }
 
  if (document.getElementById('flashwrapper')) {
 document.getElementById('flashwrapper').style.display = 'none'; }

}




function clearAllTabs(menu) {
if (menu==2)
	{
document.getElementById('tab11').style.display='none';
document.getElementById('link11').className='normal';

document.getElementById('tab12').style.display='none';
document.getElementById('link12').className='normal';

document.getElementById('tab20').style.display='none';
document.getElementById('link20').className='normal';

document.getElementById('tab30').style.display='none';
document.getElementById('link30').className='normal';

document.getElementById('tab40').style.display='none';
document.getElementById('link40').className='normal';

	}
if (menu==1)
	{
document.getElementById('tab1').style.display='none';
document.getElementById('link1').className='normal';

document.getElementById('tab2').style.display='none';
document.getElementById('link2').className='normal';

document.getElementById('tab40').style.display='none';
document.getElementById('link40').className='normal';
	}	


}

function selectTab(menu, id) {
clearAllTabs(menu);
document.getElementById('link'+id).className='current';
//document.getElementById('tab'+id).style.display='inline';
var changetab = '#tab'+id;
 //$(changetab).fadeIn('');
 $(changetab).show();
}


function processplus(v){
document.getElementById('v').value++;
}

function minusplus(v){
if (document.getElementById('v').value>1)
	{
	document.getElementById('v').value--;
	}
}




//////dynamic search fade
$('#inputString').click(function() {
  $('#testing').fadeOut();
});

	function lookup(inputString) {
		if(inputString.length > 2) {
		
			$.post("/rpc-search.php", {queryString: ""+inputString+""}, function(data){
			if(data.length > 10) {
				$('#suggestions').fadeIn();
				$('#autoSuggestionsList').html(data);
			}
		});
			
		} else {
			// Hide the suggestion box.
			$('#suggestions').fadeOut();
		
		}
	} // lookup
	
	function fill(thisValue) {
		$('#inputString').val(thisValue);
		setTimeout("$('#suggestions').fadeOut();", 200);
	}
	
function isSearchValid() {
 var qstring=document.search_form.q.value;
 
 //alert(qstring);
 if ((qstring.length < 1) || (qstring == 'Enter Search Here')){
  $('#inputString').val('');
  $('#inputString').focus();
  return false;
 }
 //else alert ('Invalid data.')
 return true;
}
	


//////







function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}



function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}






/////////ajax from main2.tpl
function createRequestObject() {
     var ro;     
     ro = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
     return ro;
}
 
var http = createRequestObject(); 
var addon = '&time='+Math.random()*Math.random();
 
function sndReq(action) {
     http.open('get', '/addtocomparefloat.php?action='+action+addon);
     http.onreadystatechange = handleResponse;
     http.send(null);
     
     //pageTracker._trackEvent('Shortlist', 'Add', '');
}

function sndReqremove(action) {
     http.open('get', '/addtocomparefloatremove.php?action='+action+addon);
     http.onreadystatechange = handleResponse;
     http.send(null);
     
    // pageTracker._trackEvent('Shortlist', 'Remove', '');
}
 
function handleResponse() {
    // if(http.readyState == 4){
          var response = http.responseText;
          var update = new Array();
 
          if(response.indexOf('|') != -1) {
               update = response.split('|');


var productElement = document.getElementById(update[0]);
if (productElement != null)
{
document.getElementById(update[0]).innerHTML = update[1];
}

	document.getElementById('comparetop').innerHTML = update[3];
	 
          }
		  


   //  }
}
/////////ajax from main2.tpl










var onload_handlers = new Array();
var timeout;

//
// Show/hide any tag by its id.
// parameters:
// id - element id
function fn_show_tag(id, status, stop_listen)
{
	if (document.getElementById(id)) {
		if (status == true || status == false) {
			document.getElementById(id).style.display = (status == true)?"none":"";
		} else {
			document.getElementById(id).style.display = (document.getElementById(id).style.display == "")?"none":"";
		}
	}

	if (stop_listen == true) {
		window.onscroll = '';
	}
}

//
// Select text in text input
//
function fn_select_input(select)
{
	select.select();
}

//
// Disable/enable all form elements inside the tag 
// @id - element id
// @status - boolean (true to disable and false to enable)
function fn_disable_elements(id, status)
{

	node = document.getElementById(id);
	// Process INPUT types...
	inputs = node.getElementsByTagName('INPUT');
	for (i=0;i<inputs.length;i++) {
		node.getElementsByTagName('INPUT')[i].disabled = status;
	}

	// Process TEXTAREA type...
	texts = node.getElementsByTagName('TEXTAREA');
	for (i=0;i<texts.length;i++) {
		node.getElementsByTagName('TEXTAREA')[i].disabled = status;
	}

	// Process SELECT type...
	selects = node.getElementsByTagName('SELECT');
	for (i=0;i<selects.length;i++) {
		node.getElementsByTagName('SELECT')[i].disabled = status;
	}
}

//
// Open pop-up window with detailed image
//
function fn_open_popup_image(popup_script, image_width, image_height)
{
	if (image_width == 0) {
		image_width = 400;
	}
	if (image_height == 0) {
		image_height = 400;
	}
	image_width += 10;
	image_height += 10;

	if ((typeof(handle_popup_image)!='undefined') && (handle_popup_image.closed == false)) {
		handle_popup_image.close();
	}
    handle_popup_image = window.open(popup_script, 'popup_image', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,left=200,top=100,width=' + image_width + ',height=' + image_height + ',resizable=yes');
}

function fn_escape_url(query) 
{
	var start = query.substr(0, query.indexOf('?'));
	var search = query.substr(query.indexOf('?'));
	if (search) {
		var srch_array = search.split("&");
		var temp_array = new Array();
		for (var i = 0; i < srch_array.length; i++) {
			temp_array = srch_array[i].split("=");
			start += temp_array[0] + '=' + escape(unescape(temp_array[1])) + '&'
		}
	}
	return start;
}

//
// Perform request via <SCRIPT> tag
//
function fn_http_request(script_id, url, show_status)
{
    var agt=navigator.userAgent.toLowerCase();
    var needs_escaping = ((agt.indexOf("msie") != -1) || (agt.indexOf("opera") != -1));

	if (needs_escaping) { 
		url = fn_escape_url(url);
	}

	if (typeof(show_status) == "undefined") {
		show_status = true;
	}

	if (show_status == true){
	//	fn_switch_loading_msg(false);
	}

	var now = new Date();
	url = url + '&prevent_cache='+now.getTime(); // Prevent script from caching

	var script_tag = document.getElementById(script_id);
	if (script_tag) {
		script_tag.parentNode.removeChild(script_tag);
	}

	script_tag = document.createElement('SCRIPT');
	script_tag.type = 'text/javascript';
	script_tag.language = 'javascript';
	script_tag.id = script_id;
    script_tag.src = url;
	document.body.appendChild(script_tag);
}

//
// String utility functions
//

// extract front part of string prior to searchString
function fn_str_get_front(mainStr,searchStr)
{
	foundOffset = mainStr.indexOf(searchStr)
	if (foundOffset == -1) {
		return null
	}
	
	return mainStr.substring(0,foundOffset)
}

// extract back end of string after searchString
function fn_str_get_end(mainStr,searchStr) 
{
	foundOffset = mainStr.indexOf(searchStr)
	if (foundOffset == -1) {
		return null
	}
	
	return mainStr.substring(foundOffset+searchStr.length,mainStr.length)
}

// insert insertString immediately before searchString
function fn_str_insert_string(mainStr,searchStr,insertStr) 
{
	var front = fn_str_get_front(mainStr,searchStr)
	var end = fn_str_get_end(mainStr,searchStr)

	if (front != null && end != null) {
		return front + insertStr + searchStr + end
	}
	
	return null
}

// remove deleteString
function fn_str_delete_string(mainStr,deleteStr) 
{
	return fn_str_replace_string(mainStr,deleteStr,"");
}

// replace searchString with replaceString
function fn_str_replace_string(mainStr,searchStr,replaceStr) 
{
	var front = fn_str_get_front(mainStr,searchStr)
	var end = fn_str_get_end(mainStr,searchStr)

	if (front != null && end != null) {
		return front + replaceStr + end
	}
	
	return mainStr;
}

// Compare 2 strings
// @haystack - where search
// @needle - what search
// @strict - exact compare or partial
function fn_compare_strings(haystack, needle, strict)
{
	if (strict == true) {
		return (haystack == needle);
	} else {
		return (haystack.indexOf(needle) == -1) ? false : true;
	}
}


//
// Check / uncheck all checkboxes in form
// @form_name - form name whose checkboxes should be checked or unchecked
// @checkbox_id - tag identifier of checkboxes that should be checked or unchecked
// @flag - can be true or false
function fn_check_all_checkboxes(form_name, flag, checkbox_id, strict)
{
	if (!checkbox_id) {
		checkbox_id = 'delete_checkbox';
	}

	if (typeof(strict) == 'undefined') {
		strict = true;
	}

	if(!(d_form = document.forms[form_name]))
		return false;

	for(i=0; i < d_form.length; i++) {
		if (fn_compare_strings(d_form.elements[i].id, checkbox_id, strict) && !d_form.elements[i].disabled)
			d_form.elements[i].checked = flag;
	}
	return true;
}

// Check email address for validity
function fn_check_email(email, msg) {

	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(email)) {
		return true;
	} else{
		alert(msg);
		return false;
	}
}






///added by kpn
function IsKishorePhone(sText)
{
var stripped = sText.replace(/[\(\)\.\-\ ]/g, '');
//strip out acceptable non-numeric characters
if (isNaN(parseInt(stripped))) {
   //error = "The phone number contains illegal characters.";
	return false;
}
}




//
// This function checks required fields and set a mark if something wrong
//
function fn_check_fields(form_name, extra_ids)
{
	var is_ok = true;
	var seqb_exists = document.getElementById('seqb');
	var error_fields = new Array();

	if (!document.forms[form_name]) {
		return false;
	}


	
	var is_ok = true;
	var set_mark = false;
	
	
//var phonevalue = document.getElementById('elm_9');

//alert(phonevalue.value);
	
//mod by kishore for phone
//if (isPhoneNumber(phonevalue.value) == false) {
//is_ok = false;
//set_mark = true;
//alert('The telephone number you entered appears to be incorrect');
//}
//mod by kishore for phone

	

	elms = document.forms[form_name].elements;
	for (i=0; i<elms.length; i++) {
		set_mark = false;






		// Check the email field
		if (typeof(extra_ids) != 'undefined' && extra_ids[elms[i].id] == 'E') {
			
			if (fn_check_email(elms[i].value, email_invalid) == false) {
				if (required_fields[elms[i].id] == 'Y' || fn_is_blank(elms[i].value) == false) {
					is_ok = false;
					set_mark = true;
				}
			}
		// Check for integer field
		} else if (typeof(extra_ids) != 'undefined' && extra_ids[elms[i].id] == 'I') {
			if (fn_is_integer(elms[i].value) == false) {
				if (required_fields[elms[i].id] == 'Y' || fn_is_blank(elms[i].value) == false) {
					is_ok = false;
					set_mark = true;
				}
			}
		// Check for phone number
		} else if (typeof(extra_ids) != 'undefined' && extra_ids[elms[i].id] == 'P') {
				
			if (fn_is_phone(elms[i].value, phone_invalid) == false) {
				if (required_fields[elms[i].id] == 'Y' || fn_is_blank(elms[i].value) == false) {
					is_ok = false;
					set_mark = true;
				}
			}
		
		// Check for phone number (kishore version)
		
		//var phonevalue = document.getElementById('elm_9');
		
		} else if ([elms[i].id] == 'elm_9') {
				//alert('phone');
			if (elms[i].value && IsKishorePhone(elms[i].value) == false) {
				
					is_ok = false;
					set_mark = true;
					alert('Please enter a valid phone number');
			
			}
			
			
		// Check for blank value
		} else {

			if (required_fields[elms[i].id] == 'Y' && fn_is_blank(elms[i].value) == true) {
				is_ok = false;
				set_mark = true;
				error_fields[elms[i].id] = true;
				if (seqb_exists && document.getElementById('seqb').checked == true && typeof(fn_check_if_shipping) == 'function' && fn_check_if_shipping(elms[i].id)) {
					document.getElementById('seqb').click();
				}
			}
		}
		if (document.getElementById('status_'+elms[i].id)) {
			document.getElementById('status_'+elms[i].id).innerHTML = (set_mark == true)? warning_mark : "&nbsp;";
		}
	}

	if (is_ok == false) {
		alert(message);
	}
	return is_ok;
}

//
// Checks if the value is blank
//
function fn_is_blank(val){
	if (val==null){
		return true;
	}
	for (var i=0; i<val.length; i++) {
		if((val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){
			return false;
		}
	}
	return true;
}

//
// Checks if the value is integer
//
function fn_is_integer(val)
{
	if(fn_is_blank(val)){
		return false;
	}
	for(var i=0; i<val.length; i++){
		if (!fn_is_digit(val.charAt(i))) {
			return false;
		}
	}
	return true;
}

//
// Checks if the value is digit
//
function fn_is_digit(num)
{
	if(num.length>1){
		return false;
	}
	var string="1234567890";
	if (string.indexOf(num)!=-1){
		return true;
	}
	return false;
}


//
// Checks if the value is phone number
//
function fn_is_phone(phone)
{
	
	//alert('test');
	phone = phone.str_replace(' ', '');
	return fn_is_integer(phone.replace(/[\+\(\)-]/gi, ''));
}

//
// Execute functions on page load
//
function fn_load_handlers()
{
	var i=0;
	for (i=0; i<onload_handlers.length; i++) {
		eval(onload_handlers[i]);
	}

	// If selected_section parameter is passed, add location hash
	var re = new RegExp();
	re.compile("selected_section=\(\\w\)+", "g");
	var m = location.href.match(re);
	if (m) {
		var hash = m[0].split('=');
		location.hash = '#'+hash[1];
	}
}

function fn_show_section(id, scts, redraw_all)
{

	// Fix bug with changing hash string in opera 8.5+
	/*if (is_opera && document_loaded == false) {
		onload_handlers.push("fn_show_section('"+id+"', sections ,'"+separate_form+"', "+redraw_all+");");
		return;
	}*/

	for (i in scts)
	{
		if (i == id) {
			if (document.getElementById('content_'+i)) {
				document.getElementById('content_'+i).style.display = '';
			}
			document.getElementById('tab_'+i+'_bg').className = 'section-active-tab-bg';
			document.getElementById('tab_'+i+'_left').src = tab_left_active_image_path;
			document.getElementById('tab_'+i+'_right').src = tab_right_active_image_path;
			if (document.getElementsByName('selected_section')) {
				elms = document.getElementsByName('selected_section');
				for (var k=0; k<elms.length; k++) {
					elms[k].value = id;
				}
				location.hash = '#'+id;
			}
		} else {
			if (document.getElementById('tab_'+i+'_bg').className == 'section-active-tab-bg' || redraw_all) {
				if (document.getElementById('content_'+i)) {
					document.getElementById('content_'+i).style.display = 'none';
				}
				document.getElementById('tab_'+i+'_bg').className = 'section-inactive-tab-bg';
				document.getElementById('tab_'+i+'_left').src = tab_left_image_path;
				document.getElementById('tab_'+i+'_right').src = tab_right_image_path;
			}
		}
	}
}

function fn_get_window_sizes()
{
	var wnd_arr = new Array();

	if (window.height) {
		wnd_arr['offset_x'] = self.pageXOffset;
		wnd_arr['offset_y'] = self.pageYOffset;
		wnd_arr['view_height'] = self.innerHeight;
		wnd_arr['view_width'] = self.innerWidth;
		wnd_arr['height'] = window.height;
		wnd_arr['width'] = window.width;
	} else {
		wnd_arr['offset_x'] = document.body.scrollLeft;
		wnd_arr['offset_y'] = document.body.scrollTop;
		wnd_arr['view_height'] = document.body.clientHeight;
		wnd_arr['view_width'] = document.body.clientWidth;
		wnd_arr['height'] = document.body.scrollHeight;
		wnd_arr['width'] = document.body.scrollWidth;
	}

	return wnd_arr;
}

function fn_switch_loading_msg(status)
{
	var dlg = document.getElementById('dialog_bg');
	var msg = document.getElementById('dialog_msg');

	var wnd_sizes = fn_get_window_sizes();
	dlg.style.left = 0;
	dlg.style.top = 0;
	dlg.style.width=wnd_sizes['width'];
	dlg.style.height=wnd_sizes['height'];

	msg.style.left = wnd_sizes['offset_x'];
	msg.style.top = wnd_sizes['offset_y'];
	msg.style.width = wnd_sizes['view_width'];
	msg.style.height = wnd_sizes['view_height'];

	fn_show_tag('dialog_bg', status);
}

function fn_check_selected(form_name, checkbox_id, no_alert, strict)
{
	if (typeof(strict) == 'undefined') {
		strict = true;
	}
	
	if (!checkbox_id) {
		checkbox_id = 'delete_checkbox';
	}

	if(!(d_form = document.forms[form_name])) {
		return false;
	}

	for(i=0; i < d_form.length; i++) {
		if (fn_compare_strings(d_form.elements[i].id, checkbox_id, strict)) {
			if (d_form.elements[i].checked) {
				return true;
			}
		}
	}
	if (!no_alert) {
		alert(error_no_items_selected);
	}
	return false;
}

function fn_delete_selected(form_name, mode_value, no_confirmation, checkbox_id, elm_name, strict) 
{

	if (typeof(strict) == 'undefined') {
		strict = true;
	}
	if (!fn_check_selected(form_name, checkbox_id, '', strict)) {
		return false;
	}
	if (!no_confirmation) {
		if (!confirm(text_delete_confirmation)) {
			return false;
		}
	}

	if (typeof(elm_name)== 'undefined' || elm_name.length == 0) {
		elm_name = mode_name;
	}

	document.forms[form_name].elements[elm_name].value = mode_value;
	document.forms[form_name].submit();
	return true;
}

function fn_ajax_update_vars(page, url, msg)
{
	// Set page input field to current page
	if (page.length > 0) {
		elms = document.getElementsByName('page');
		if (elms.length>0) {
			for (var i=0; i<elms.length; i++) {
				elms[i].value=page;
			}
		}
	}

	if (url.length > 0) {
		elms = document.getElementsByName('redirect_url');
		if (elms.length>0) {
			for (var i=0; i<elms.length; i++) {
				elms[i].value=url;
			}
		}
	}

	if (msg.length > 0) {
		//window.onscroll = fn_align_element;
		document.getElementById('ajax_message').innerHTML = msg;
		document.getElementById('ajax_message').style.display = 'block';
		//fn_align_element();
		//fn_show_tag('ajax_message', false);
		//window.setTimeout("fn_show_tag('ajax_message', true, true);", 5000);
	}

	if (typeof(fn_check_all_exceptions) == 'function') {
		fn_check_all_exceptions(false);
	}

	//fn_switch_loading_msg(true);
}

function fn_align_element()
{
	var wnd_sizes = fn_get_window_sizes();
	msg = document.getElementById('ajax_message');
	//msg.style.top = wnd_sizes['offset_y'] + (wnd_sizes['view_height'] - parseInt(msg.style.height)) / 2;
	//msg.style.left = wnd_sizes['offset_x'] + (wnd_sizes['view_width'] - parseInt(msg.style.width)) / 2;
}

function fn_format_num(expr, decplaces, primary)
{
	var num = '';
	var decimals = '';
	var tmp = 0;
	var k = 0;
	var i = 0;
	var thousands_separator = (primary == true) ? primary_thousands_separator : secondary_thousands_separator;
	var decimals_separator = (primary == true) ? primary_decimals_separator : secondary_decimals_separator;

	expr = fn_format_price(expr, decplaces);
	frac_part = expr.substr(expr.indexOf('.')+1) + '0000';
	num = parseInt(expr).toString();

	// Separate thousands
	if (num.length >= 4 && thousands_separator != '') {
		tmp = new Array();
		for (var i=num.length-3; i>-4 ; i=i-3) {
			k = 3;
			if (i<0) {
				k = 3 + i;
				i=0;
			}
			tmp.push(num.substr(i,k));
			if (i==0) {
				break;
			}
		}
		num = tmp.reverse().join(thousands_separator);
	}

	// Add decimals
	if (decplaces > 0) {
		num += decimals_separator + frac_part.substr(0, decplaces);
	}
	
	return num;
}

function fn_blink(cycle)
{
	if (cycle > 6) {
		be.style.visibility = 'visible';
		clearTimeout(timeout);
		return;
	}
	cycle++;
	if (be = document.getElementById('blinking_elm')) {
		be.style.visibility = (be.style.visibility == 'visible') ? 'hidden' : 'visible';
		timeout = window.setTimeout('fn_blink('+cycle+')', 500);
	}
}

function fn_form_get_request(form_name)
{
	var i = 0;
	var url = index_script + '?';

	if (document.forms[form_name]) {
		elms = document.forms[form_name].elements;
		for (i = 0; i < elms.length ; i++) {
			if (((elms[i].type == 'checkbox' || elms[i].type == 'radio') && elms[i].checked == false) || elms[i].disabled == true) {
				continue;
			}
			url += elms[i].name + '=' + elms[i].value + '&'
		}

		return url;
	}

	return false;
}

function fn_format_price(value, decplaces)
{
	if (typeof(decplaces) == 'undefined') {
		decplaces = 2;
	}

	value = parseFloat(value.toString()) + 0.00000000001;
	return value.toFixed(decplaces);
}

String.prototype.str_replace = function(src, dst)
{

	return this.toString().split(src).join(dst);
}
