
function removeHTMLTags(strInputCode)
{strInputCode=strInputCode.replace(/&(lt|gt);/g,function(strMatch,p1){return(p1=="lt")?"<":">";});var strTagStrippedText=strInputCode.replace(/<\/?[^>]+(>|$)/g,"");return strTagStrippedText;}
function stripHTML(sin)
{sin=removeHTMLTags(sin);return sin.replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,"$1");}
document.observe('lightview:loaded', function() {
window.alert=function modalPopup(msg)
{
   
        Lightview.show({ href: 'alert.aspx?msg='+msg, title:'There has been an error!', rel: 'iframe', options: { width: 300, height:100, topclose: true }});
     
}
});
function getParams()
{var idx=document.URL.indexOf('?');var params=new Array();if(idx!=-1)
{var pairs=document.URL.substring(idx+1,document.URL.length).split('&');for(var i=0;i<pairs.length;i++)
{nameVal=pairs[i].split('=');params[nameVal[0]]=nameVal[1];}}
return params;}
function getParamsbyref()
{paramsbyref=getParamsbyrefString(document.URL);return paramsbyref;}
function getParamsbyrefString(url)
{var idx=url.indexOf('?');var paramsbyref=new Array();if(idx!=-1)
{var pairs=url.substring(idx+1,url.length).split('&');for(var i=0;i<pairs.length;i++)
{nameVal=pairs[i].split('=');paramsbyref[i]=nameVal;}}
return paramsbyref;}
function setParam(id,value)
{paramsbyref=getParamsbyref();var url='not';if(document.URL.indexOf('?')==-1)
{url="?"+id+"="+value;}
else if(document.URL.indexOf("&"+id+"=")!=-1||document.URL.indexOf("?"+id+"=")!=-1)
{url="?";for(var i=0;i<paramsbyref.length;i++)
{if(i!=0)
url+="&";url+=paramsbyref[i][0]+"=";if(paramsbyref[i][0]!=id)
url+=paramsbyref[i][1];else
url+=value;}
url=removeParamString("pagenum",url);}
else
{var idx=document.URL.indexOf('?');url="?"+document.URL.substring(idx+1,document.URL.length)+"&"+id+"="+value;url=removeParamString("pagenum",url);}
document.location.href=url;}
function removeParamString(id,instring)
{if(instring=="")
paramsbyref=getParamsbyref();else
paramsbyref=getParamsbyrefString(instring);var url="";for(var i=0;i<paramsbyref.length;i++)
{if(paramsbyref[i][0]!=id)
{if(url.length!=0)
url+="&";else
url+="?";url+=paramsbyref[i][0]+"="+paramsbyref[i][1];}}
if(url=="")
{var idx=document.URL.indexOf('?');url=document.URL.substring(0,idx);}
return url;}
function removeParam(id)
{var url=removeParamString(id,"");document.location.href=url;}
function sectionLink(sec)
{params=getParams();if(params["sections"]!=null&&params["sections"].match(","+sec+",")==","+sec+",")
{return;}
if(params["sections"]!=null)
var querystring=params["sections"]+sec+",";else
var querystring=","+sec+",";setParam('sections',querystring);}
function setActiveSection(id,name,parentname)
{document.getElementById(parentname+"Selected").innerHTML+=name+" (<a href='javascript:removeSection("+id+");' class='removeLink' >remove</a>)";document.getElementById(parentname+"Selected2").innerHTML+=name+" (<a href='javascript:removeSection("+id+");' class='removeLink' >remove</a>) ,";var showSelected=true;document.getElementById(parentname+"Unselected").style.display="none";document.getElementById(parentname+"Selected").style.display="block";document.getElementById('allSelections').style.display="block";document.getElementById('TopSelectionsBar').style.display="block";
    if (document.getElementById('ClearanceBar'))
    {
    document.getElementById('ClearanceBar').style.display="none";
    }
}
function removeSection(id)
{params=getParams();var out=removeID(params["sections"],","+id+",");if(out==",")
removeParam("sections");else
setParam("sections",out);}
function removeID(s,t)
{i=s.indexOf(t);r="";if(i==-1)return s;r+=s.substring(0,i)+","+removeID(s.substring(i+t.length),t);return r;}
var selectedArray=new Array();var showSelected=false;params=getParams();function show(sid,name,sectionname)
{if(params["sections"]!=null&&params["sections"].match(","+sid+",")==","+sid+",")
{selectedArray.push([sid,name,sectionname]);}
document.getElementById(sectionname+"Header").style.display="block";}

function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}
function clickrecall(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}



function validatePriceForm() 
{
    with (document.pricepromise) 
    {
        var alertMsg = "The following REQUIRED fields\nhave been left empty:<br><br>\n";
        if (customername.value == "") alertMsg += "\nName<br>";
        if (customeremail.value == "") alertMsg += "\nEmail<br>";
        if (customerphone.value == "") alertMsg += "\nContact Telephone<br>";
        if (productname.value == "") alertMsg += "\nProduct Name<br>";
        if (productsize.value == "") alertMsg += "\nProduct Size<br>";
        if (productprice.value == "") alertMsg += "\nProduct Price<br>";
        if (website.value == "") alertMsg += "\nDetails of the website you saw the product";
        if (alertMsg != "The following REQUIRED fields\nhave been left empty:<br><br>\n") 
    {
        alert(alertMsg);
        return false;
    } 
        else 
    {
        return true;
    }   
} }


function validateTesterForm() 
{
    with (document.producttester) 
    {
        var alertMsg = "The following REQUIRED fields\nhave been left empty:<br><br>\n";
        if (customer_name.value == "") alertMsg += "\nName<br>";
        if (customer_email.value == "") alertMsg += "\nEmail<br>";
        if (customer_website.value == "") alertMsg += "\nYour Website / Blog<br>";
        if (customer_website_about.value == "") alertMsg += "\nYour Websie / Blog Subject<br>";
        if (permission.value == "") alertMsg += "\nPlease confirm you have permission to post on this website / blog<br>";
        if (customer_interest.value == "") alertMsg += "\nWhich product type are you interested in";
        if (alertMsg != "The following REQUIRED fields\nhave been left empty:<br><br>\n") 
    {
        if (document.getElementById('errorBox')) {
            document.getElementById('errorBox').innerHTML = alertMsg;
            Lightview.show({ href: '#errorBox', title: 'There has been an error!', options: { width: 300, height: 100, topclose: true} });
        }
        return false;
    } 
        else 
    {
        return true;
    }   
} }
