
var r_address=0;function resize(theElem,stepSize,minSize,maxSize)
{if(theElem==null||theElem.rows==null||theElem.cols==null||theElem.value==null)return;if(stepSize==null||stepSize<1)stepSize=5;var rowContent=theElem.value.split('\n');var rowCount=rowContent.length;if(theElem.cols>0)
for(i=0;i<rowContent.length;i++)
rowCount+=Math.floor(rowContent[i].length/theElem.cols);rowCount=Math.floor(rowCount/stepSize)*stepSize+stepSize;if(minSize!=null&&minSize>rowCount)rowCount=minSize;if(maxSize!=null&&maxSize>minSize&&maxSize<rowCount)rowCount=maxSize;theElem.rows=rowCount;}
function setValue(name,value)
{var elem=getElement(name);if(elem!=null)setElement(elem,value);}
function setClass(name,value)
{var elem=getElement(name);if(elem!=null&&elem.className!=null)elem.className=value;}
function setAllValues(name,value)
{var elemList=getElements(name);if(elemList.length>0)
for(var i=0;i<elemList.length;i++)
setElement(elemList[i],value);}
function getElements(name)
{var elemList=document.getElementsByName(name);if(document.all!=null&&elemList.length==0)
{elemList=new Array();for(var key in document.all)
if(document.all[key].name==name)
elemList[elemList.length]=document.all[key];}
var idElem=document.getElementById(name);if(idElem!=null)elemList[elemList.length]=idElem;return elemList;}
function getElement(name)
{var elem=document.getElementById(name);if(elem)return elem;elem=document.getElementsByName(name);if(elem.length>0)return elem[0];if(document.all!=null)
{for(var key in document.all)
{if(document.all[key].id==name)return document.all[key];if(document.all[key].name==name)return document.all[key];}}
return null;}
function setElement(elem,value)
{if(elem.tagName=='SELECT')
for(var i=0;i<elem.options.length;i++)
if(elem.options[i].value==value)
{elem.options[i].selected=true;elem.selectedIndex=i;}
else
elem.options[i].selected=false;if(elem.tagName=='SPAN'||elem.tagName=='DIV')
{elem.innerText=value;elem.innerHTML=value;}
if(elem.value!=null)elem.value=value;else if(elem.innerHTML)elem.innerHTML=value;}
function getValue(name)
{var elem=getElement(name);if(elem==null)return null;if(elem.type!=null&&elem.type=='radio')
{elem=getElements(name);for(var i=0;i<elem.length;i++)
{if(elem[i].checked)
return elem[i].value;}
return null;}
if(elem.value!=null)return elem.value;if(elem.innerHTML!=null)return elem.innerHTML;return null;}
function addTableRow(theTable,newName,rownum)
{if(rownum==null)rownum=theTable.rows.length;var newRow=theTable.insertRow(rownum);newRow.name=newName;newRow.id=newName;return newRow;}
function addTableCell(tableRow,innerStuff)
{var newCol=document.createElement('td');newCol.innerHTML=innerStuff;tableRow.appendChild(newCol);return newCol;}
function toggleSection(sectionName,force)
{var theSect=getElement(sectionName);var hideNote=getElement(sectionName+'_hideNote');if(theSect==null)return;var newDisplay=(theSect.style.display=='none');if(force!=null)newDisplay=force;if(newDisplay==true)
{theSect.style.display='';if(hideNote!=null)hideNote.style.display='none';}
else
{theSect.style.display='none';if(hideNote!=null)hideNote.style.display='';}}
function setSelectOptions(name,newOptions)
{var elem=getElement(name);if(elem==null)return;elem.options.length=0;for(var key in newOptions)
elem.options[elem.options.length]=new Option(newOptions[key],key);}
function togglePic(name)
{var elem=getElement(name);if(elem.style.display=='none')
getElement(name+'ImEx').src='/images/triDown.gif';else
getElement(name+'ImEx').src='/images/triUp.gif';}
function change(id,newClass)
{identity=document.getElementById(id);identity.className=newClass;if(navigator.userAgent.toLowerCase().indexOf('msie')>1)
return;if(newClass=="Alt")
{identity.style.backgroundColor="#C0C0C0";identity.style.fontSize="12px";identity.style.color="#960A0B";}
else
{identity.style.backgroundColor="#ECECEC;";identity.style.fontSize="12px";identity.style.color="#373E48";}}
function in_array(array,value)
{var found=false;for(key in array){if(array[key]===value){found=true;break;}}
return found;}
function openWindow(url,w,h,centered)
{if(centered==null)centered=false;var features='width='+w+', height='+h;if(centered)features+=', top='+((screen.height-h)/2)+', left='+((screen.width-w)/2);window.open(url,'',features);}
function validate(ar,collection)
{for(key in collection){var elem=collection[key];var name=elem.charAt(0).toUpperCase()+elem.substring(1);if(ar!='')elem=ar+'['+elem+']';if(collection[key]=='email'){if(!isValidEmail(getValue(elem))){alert('The Email is empty or invalid.');return false;}}
else if(getValue(elem)==''){alert('The '+name+' is empty.');return false;}}
return true;}
function explode(str_separator,str_string)
{return str_string.split(str_separator);}
function implode(str_glue,arr_pieces)
{return arr_pieces.join(str_glue);}
function isValidEmail(email_address)
{var regex=/("[^"]{1,62}"|[a-zA-Z_-][a-zA-Z0-9_-]{0,64})\@(\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\]|[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.[a-zA-Z]{2,6})/;return regex.test(email_address);}
function validateProductSearch()
{if(getValue('signal_from')==''&&getValue('signal_to')==''&&getValue('connection_from')==''&&getValue('connection_to')==''){alert('Search is empty.');return false;}
return true;}
function checkAllCompares(selectElem)
{var elem=getElement(selectElem);var col=document.getElementsByName('compare[]');for(var i=0;i<col.length;i++)
var obj=col[i].checked=elem.checked;for(i=0;i<15;i++){var name='select_all_'+i;var obj=getElement(name);if(!obj||obj==null)break;if(name!=selectElem){obj.checked=getElement(selectElem).checked;}}}
function compareSubmit(form)
{var count=0;var col=document.getElementsByName('compare[]');for(var i=0;i<col.length;i++){if(col[i].checked)
count++;}
if(count>=2)form.submit();else{alert('Please select at least 2 products to compare');return false;}}
function addResellerAddress()
{var con_table=getElement('resellers');if(con_table==null)return;var newRow=addTableRow(con_table,'contact_row['+r_address+']');addTableCell(newRow,'<table align="center" style="width:100%;font-size:11px;border:1px solid #CCCCCC;" border=0 bordercolor="#CCCCCC" cellpadding=2><tr><td class="left_title" style="width:20%">Company Name :</td><td style="width:30%;padding:2px 0px 2px 5px;"><input style="width:96%" type="text" name="reseller['+r_address+'][company_name]" value="" /></td><td class="left_title" style="width:20%">Main Phone Number :</td><td style="width:30%;padding:2px 0px 2px 5px;"><input style="width:96%" type="text" name="reseller['+r_address+'][phone_no]" value="" /></td></tr><tr><td class="left_title" style="width:20%">Street Address :</td><td style="width:30%;padding:2px 0px 2px 5px;"><textarea name="reseller['+r_address+'][address]" style="width:96%;height:75px;"></textarea></td><td class="left_title" style="width:20%" valign="top">2nd Contact Number :</td><td style="width:30%;padding:2px 0px 2px 5px;" valign="top"><input style="width:96%" type="text" name="reseller['+r_address+'][phone_no2]" value="" /></td></tr><tr><td class="left_title" style="width:20%">City :</td><td style="width:30%;padding:2px 0px 2px 5px;"><input style="width:96%" type="text" name="reseller['+r_address+'][city]" value="" /></td><td class="left_title" style="width:20%">Mobile :</td><td style="width:30%;padding:2px 0px 2px 5px;"><input style="width:96%" type="text" name="reseller['+r_address+'][mobile_no]" value="" /></td></tr><tr><td class="left_title" style="width:20%">Zip/Post Code :</td><td style="width:30%;padding:2px 0px 2px 5px;"><input style="width:96%" type="text" name="reseller['+r_address+'][post_code]" value="" /></td><td class="left_title" style="width:20%">Fax :</td><td style="width:30%;padding:2px 0px 2px 5px;"><input style="width:96%" type="text" name="reseller['+r_address+'][fax_no]" value="" /></td></tr><tr><td class="left_title" style="width:20%">State :</td><td style="width:30%;padding:2px 0px 2px 5px;"><input style="width:96%" type="text" name="reseller['+r_address+'][state]" value="" /></td><td class="left_title" style="width:20%">Website :</td><td style="width:30%;padding:2px 0px 2px 5px;"><input style="width:96%" type="text" name="reseller['+r_address+'][website]" value="" /></td><tr><td class="left_title" style="width:20%">Country :</td><td style="width:30%;padding:2px 0px 2px 5px;"><select name="reseller['+r_address+'][country]" style="width:98%"><option value="">Please Choose Country</option>'+country_list+'</select></td><td class="left_title" colspan=2>&nbsp;</td></tr></table>');r_address++;}
function nextStep(number,curSection,section)
{if(Number(number)!=4){window.frames[number].document.forms[0].target=section;window.frames[number].document.forms[0].submit();getElement(section).style.display='';getElement(section+'_btn').style.display='';}
else{window.frames[number].document.forms[0].target='_blank';window.frames[number].document.forms[0].action='display_results.html';window.frames[number].document.forms[0].submit();}}
function calcIFrameHeight(iframe)
{var theFrame=getElement(iframe);if(theFrame==''||theFrame==null)return;var newHeight=theFrame.contentWindow.document.body.scrollHeight;theFrame.height=Math.max(Number(newHeight)+16,50);theFrame.style.height=Math.max(Number(newHeight)+16,50);}
function checkAll(section,id,ids)
{var elem=getElement('signal_'+section+'['+id+']');var ar=ids.split('_');for(key in ar){var obj=getElement('signals_'+section+'['+ar[key]+']');obj.checked=elem.checked;}}
function changeCurrency()
{var currency=getElement('currency').value;var newLocation='/change_currency.html?action=change&newCurrency='+currency;this.location=newLocation;}
function freightQuote(product_id,qty)
{if(product_id==null)return;if(qty==null)qty=1;var script='/freight/freight_'+product_id+'_'+qty+'.html';openWindow(script,'850','650',true);}
function ShowShip(Vis,DivID)
{var theSect=getElement(DivID);if(theSect==null)return;theSect.style.display=Vis;}
function showGSTPrice(price,withGST)
{var obj=getElement('price');var gst_price=Number((price*1.1));getElement('gst_link').style.display=(withGST)?'none':'';getElement('gst_w_link').style.display=(withGST)?'':'none';obj.innerHTML=((withGST)?gst_price.toFixed(2):Number(price).toFixed(2))+' AUD';getElement('gst_span').innerHTML=(withGST)?'with GST':'w/o GST';}
function screenshots(product_id,shot_id)
{if(product_id==null||shot_id==null)return;var script='/screenshots/'+shot_id+'_'+product_id+'.html';var features='width=880,height=720,top=0,left=0,resizable=1';openWindow(script,880,720,true);}
function changeOpac(opacity,name,obj)
{var object=getElement(name);if(obj!=null)object=obj;object.style.opacity=(opacity/100);object.style.MozOpacity=(opacity/100);object.style.KhtmlOpacity=(opacity/100);object.style.filter="alpha(opacity="+opacity+")";}
function opacity(name,opacStart,opacEnd,millisec)
{var speed=Math.round(millisec/100);var timer=0;var tmp=(timeOut!=null)?timeOut:'';var resetTimeOut=(tmp!=null);if(timeOut)clearTimeout(timeOut);if(opacStart>opacEnd)for(i=opacStart;i>=opacEnd;i--)
{timeOut=setTimeout("changeOpac("+i+",'"+name+"')",(timer*speed));timer++;}
if(resetTimeOut){clearTimeout(timeOut);timeOut=tmp;}}
