function toggle_title_tips()
{
    var title_span = document.getElementById('title_tips');
    if (title_span.innerHTML == "&nbsp;")
    {
        title_span.innerHTML = "very important for ranking. put keywords first. keep the total number of characters under 80. 10 character minimum. be sure that every page has a unique title tag. <a href=\"javascript:void(0);\" onClick=\"MM_openBrWindow('seo_title_tags.htm','','scrollbars=yes,resizable=yes,width=600,height=500')\">more info...</a>";
    }
    else
    {
        title_span.innerHTML = "&nbsp;"
    }
}

function toggle_desc_tips()
{
    var desc_span = document.getElementById('desc_tips');
    if (desc_span.innerHTML == "&nbsp;")
    {
        desc_span.innerHTML = "200 characters maximum. 10 charactes minimum. minor effect on ranking. be sure that every page has a unique description tag.  write good descriptions that entice people to click. <a href=\"javascript:void(0);\" onClick=\"MM_openBrWindow('seo_description_tags.htm','','scrollbars=yes,resizable=yes,width=700,height=670')\">more info...</a>";
    }
    else
    {
        desc_span.innerHTML = "&nbsp;"
    }
}
function toggle_alt_tips()
{
    var desc_span = document.getElementById('alt_tips');
    if (desc_span.innerHTML == "&nbsp;")
    {
        desc_span.innerHTML = "<br />In image filenames, words must be separated with dashes. No underscores, no spaces. For example, a good filename would be: \"lamy-safari-charcoal-pen\". The ALT text should describe the picture, and should include good keywords that people might search for, so always include the word pen if it's a pen. For example, \"Lamy Safari Charcoal Pen\". Make sure each image has a unique filename and ALT text.";
    }
    else
    {
        desc_span.innerHTML = "&nbsp;"
    }
}
function toggle_url_tips()
{
    var url_span = document.getElementById('url_tips');
    if (url_span.innerHTML == "&nbsp;")
    {
        url_span.innerHTML = "Once a page has been indexed in the search engines, it starts gaining rank and trust. If you change the filename of the page, then the search engines will see it as a new page, and it will have to start from scratch. There is really only one time that a filename can be changed, and that is shortly after a page was first created, and before any SEO work has been done on the page - so, within a day or two of creating a new page. If you must change the page filename, here are the naming guidelines:<br>Example: beauty-salon-services.php<br> Try to incorporate keywords. Use lowercase alphabetic characters and dashes only - NO SPACES. NO SPECIAL CHARACTERS. 3 WORD MAXIMUM. The filename Must be unique for each page."
    }
    else
    {
        url_span.innerHTML = "&nbsp;"
    }
}   

function changeURL()
{
    var agree = confirm("PLEASE NOTE\nIT IS A VERY RARE SITUATION WHERE YOU SHOULD CHANGE AN EXISTING PAGE'S FILENAME.\nOnce a page has been indexed in the search engines, it starts gaining rank and trust. If you change the URL of the page, then the search engines will see it as a new page, and it will have to start from scratch. There is really only one time that a filename can be changed, and that is shortly after a page was first created, and before any SEO work has been done on the page - so, within a day or two of creating a new page. Are you sure you want to change this filename? Click ok if yes, cancel if no.");
    if (agree)
    {
        document.forms[1].url.disabled = false;
    }
}


if(document.getElementById("google_title") != null)
    var ori_title = document.getElementById("google_title").innerHTML;
if(document.getElementById("google_text") != null)
    var ori_text = document.getElementById("google_text").innerHTML;
if(document.getElementById("urlout") != null)
    var ori_link = document.getElementById("urlout").innerHTML;
var short_title = "";
var short_text = "";
function blurTitle()
{
    if (document.getElementById("meta_title").value == "")
        document.getElementById("google_title").innerHTML = ori_title;
}
function changeTitle()
{
    if(document.getElementById("meta_title").value.length <=70)   
        document.getElementById("google_title").innerHTML = document.getElementById("meta_title").value;
    else
    {
        short_title = document.getElementById("meta_title").value.substring(0,70);
        document.getElementById("google_title").innerHTML = document.getElementById("meta_title").value.substring(0,short_title.lastIndexOf(" ")) + "...";
    }
    
    
    if(document.getElementById("meta_title").value =="")
        document.getElementById("google_title").innerHTML = ori_title;
}
function blurText()
{
    if (document.getElementById("meta_description").value == "")
        document.getElementById("google_text").innerHTML = ori_text;
}
function changeText()
{
    
    if(document.getElementById("meta_description").value.length <=200)   
        document.getElementById("google_text").innerHTML = document.getElementById("meta_description").value;
    else
    {
        short_title = document.getElementById("meta_description").value.substring(0,200);
        document.getElementById("google_text").innerHTML = document.getElementById("meta_description").value.substring(0,short_title.lastIndexOf(" ")) + "...";
    }    
    
    
    if(document.getElementById("meta_description").value == "")
        document.getElementById("google_text").innerHTML = ori_text;
        
        
}

function blurLink()
{

    if(document.getElementById("url").value.substring(document.getElementById("url").value.length-1, document.getElementById("url").value.length) == "-")
        document.getElementById("url").value = document.getElementById("url").value.substring(0, document.getElementById("url").value.length-1);
        
    if (document.getElementById("url").value == "")
        document.getElementById("urlout").innerHTML = ori_link;
}
function changeLink()
{
    var link = document.getElementById("url").value.replace(/[^a-z\/A-Z0-9]+/g,"-");
    
    
    if(link.substring(link.length-1, link.length) == "-")
        link = link.substring(0, link.length-1);
    if(link.substring(0,1) == "-")
        link = link.substring(1,link.length);          
    document.getElementById("link").innerHTML = link.toLowerCase() + "/";
    if(document.getElementById("url").value == "")
        document.getElementById("link").innerHTML = "";
}
function changeBrand(brand)
{
    var section = brand.options[brand.selectedIndex].text;

    var link = section.replace(/[^a-z\/A-Z0-9]+/g,"-");
    
    
    if(link.substring(link.length-1, link.length) == "-")
        link = link.substring(0, link.length-1);
    if(link.substring(0,1) == "-")
        link = link.substring(1,link.length);          
    
    document.getElementById("brand").innerHTML = link.toLowerCase();
    if(brand == "")
        document.getElementById("brand").innerHTML = "brand";    
}
function textCounter(field,cntfield,maxlimit)
{
    var cntDiv = document.getElementById(cntfield);
    var totalchars = field.value.length;
    var remaining = maxlimit - field.value.length;

    if ((remaining < 0) && (totalchars >= 10))
        cntDiv.innerHTML = "Total characters: "+totalchars+" | <font color=\"red\">Remaining characters: "+remaining+"</font>";

    else
        cntDiv.innerHTML = "Total characters: "+totalchars+" | Remaining characters: "+remaining;
}

function textCounterBlock(field,cntfield,maxlimit)
{
    var cntDiv = document.getElementById(cntfield);
    var totalchars = field.value.length;
    if(totalchars > maxlimit)
    {
        field.value = field.value.substring(0,200);
        return false;
    }
    var remaining = maxlimit - field.value.length;

    if ((remaining < 0) && (totalchars >= 10))
        cntDiv.innerHTML = "Total characters: "+totalchars+" | <font color=\"red\">Remaining characters: "+remaining+"</font>";

    else
        cntDiv.innerHTML = "Total characters: "+totalchars+" | Remaining characters: "+remaining;
}

function priceMaskField(value,field_id)
{
    value = value.replace(/\$/g,"");
    document.getElementById(field_id).value = value;
}

function urlMaskFilename(value,id)
{
    if(value.substring(value.length-1, value.length) == "-")
        return;

    value = value.replace(/[^a-zA-Z0-9]+/g,"-");
    

    if(value.substring(0,1) == "-")
        value = value.substring(1,value.length);          
    value = value.toLowerCase();

    document.getElementById('filename_' + id).value = value;
}

function urlMaskField(value,field)
{
    if(value.substring(value.length-1, value.length) == "-")
        return;

    value = value.replace(/[^a-zA-Z0-9]+/g,"-");
    

    if(value.substring(0,1) == "-")
        value = value.substring(1,value.length);          
    value = value.toLowerCase();

    document.getElementById(field).value = value;
}


function urlMask(value)
{
    if(value.substring(value.length-1, value.length) == "-")
        return;

    value = value.replace(/[^a-z\/A-Z0-9]+/g,"-");
    

    if(value.substring(0,1) == "-")
        value = value.substring(1,value.length);          
    value = value.toLowerCase();

    document.getElementById('url').value = value;
}

function userMask(value)
{
    value = value.replace(/[^a-z_\-@.A-Z0-9]+/g,"");
    document.getElementById('email').value = value;
}
function nameCommentsMask(value)
{
        value = value.replace(/[^a-z_ \-@.A-Z0-9]+/g,"");
    document.getElementById('comment_name').value = value;
}

function emailCommentsMask(value)
{
        value = value.replace(/[^a-z_\-@.A-Z0-9]+/g,"");
    document.getElementById('comment_email').value = value;
}

function secondsMask(value)
{
    value = value.replace(/[^0-9]+/g,"");
    document.getElementById('interval').value = value;
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function resizeText(multiplier) {
  if (document.body.style.fontSize == "") {
    document.body.style.fontSize = "1.0em";
  }
  document.body.style.fontSize = parseFloat(document.body.style.fontSize) + (multiplier * 0.2) + "em";
}

function ssExpand(value)
{
var display = "";
    if(!bw.ieX)
        display  = 'table-row';
    else
        display = 'block';
    
    if(value ==1)
    {
        document.getElementById('screenshots-row').style.display = display;
    }
    else
    {
        document.getElementById('screenshots-row').style.display = 'none';
    }
    
}


function copyToClipboard()
{
var meintext = document.getElementById('clip_text').value;
 if (window.clipboardData) 
   {
   
   // the IE-manier
   window.clipboardData.setData("Text", meintext);
   
   // waarschijnlijk niet de beste manier om Moz/NS te detecteren;
   // het is mij echter onbekend vanaf welke versie dit precies werkt:
   }
   else if (window.netscape) 
   { 
   
   // dit is belangrijk maar staat nergens duidelijk vermeld:
   netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
   
   // maak een interface naar het clipboard
   var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
   if (!clip) return;
   
   // maak een transferable
   var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
   if (!trans) return;
   
   // specificeer wat voor soort data we op willen halen; text in dit geval
   trans.addDataFlavor('text/unicode');
   
   // om de data uit de transferable te halen hebben we 2 nieuwe objecten nodig   om het in op te slaan
   var str = new Object();
   var len = new Object();
   
   var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
   
   var copytext=meintext;
   
   str.data=copytext;
   
   trans.setTransferData("text/unicode",str,copytext.length*2);
   
   var clipid=Components.interfaces.nsIClipboard;
   
   if (!clip) return false;
   
   clip.setData(trans,null,clipid.kGlobalClipboard);
   
   }
}
/*
Allowing the site to copy the text


Internet Explorer 6

   1. Go to Tools -> Internet Options.
   2. Go to Security tab.
   3. Select “Internet” zone, then click on “Custom level…” button.
   4. Scroll down to “Scripting” section (at the bottom few).
   5. Under “Allow Paste Operations via Script” option, check or select (tick) Enable. 
   6. Click Ok twice to exit from Internet Options.

Internet Explorer 7 and later

   1. Go to Tools -> Internet Options.
   2. Go to Security tab.
   3. Select “Internet” zone, then click on “Custom level…” button.
   4. Scroll down to “Scripting” section (at the bottom few).
   5. Under “Allow Programmatic clipboard access” option, check or select (tick) Enable. 
   6. Click Ok twice to exit from Internet Options.

Firefox

   1. Paste about:config into browser address bar.
   2. Click right mouse button somewhere in active part of preference list window and choose New > Boolean option from context menu
   3. Paste signed.applets.codebase_principal_support as the Preference name into the New boolean value window input box.
   4. Set boolean value to true. Keep in mind that Preference names are case-sensitive.
   5. Restart Firefox
   6. Use the "copy this" function in your CMS.
   7. Firefox will confirm again if you allow or deny that operation, you have the option to memorize or not your option. 
   
   */

function display_pc_price(id)
{
    var price;
    if (document.add_form.pc_versions.options[document.add_form.pc_versions.selectedIndex].value == " ")
        price = "select version";
    else
        price = execAJAXCart("/get-price.php?&solution_id="+id+"&version="+document.add_form.pc_versions.options[document.add_form.pc_versions.selectedIndex].value);

    // update the html on the page
    document.getElementById('pc_price').innerHTML = price; 
}
function display_mac_price(id)
{
    var price;
    if (document.add_form.mac_versions.options[document.add_form.mac_versions.selectedIndex].value == " ")
        price = "select version";
    else
        price = execAJAXCart("/get-price.php?&solution_id="+id+"&version="+document.add_form.mac_versions.options[document.add_form.mac_versions.selectedIndex].value);

    // update the html on the page
    document.getElementById('mac_price').innerHTML = price; 
}


function isVersionSelectedPC()
{
    if (document.add_form.pc_versions.options[document.add_form.pc_versions.selectedIndex].value != " ")
        return true;
    else
        return false;
}
function isVersionSelectedMAC()
{
    if (document.add_form.mac_versions.options[document.add_form.mac_versions.selectedIndex].value != " ")
        return true;
    else
        return false;
}
 
   
function addToCart(solution_id,solution_name,platform)
{
    var selected = "";
    if (platform == "pc") selected = isVersionSelectedPC();
    else if (platform == "mac") selected = isVersionSelectedMAC();

    if(!selected)
    {
        document.getElementById("version-validator").style.display = "inline";
    }
    else
    {
        if (platform == "pc")
        {
            var version = document.add_form.pc_versions.options[document.add_form.pc_versions.selectedIndex].value;
        }
        else
        {
            var version = document.add_form.mac_versions.options[document.add_form.mac_versions.selectedIndex].value;
        }

        document.getElementById("version-validator").style.display = "none";
        var cart_content = execAJAXCart("/add_to_cart.php?&solution_id="+solution_id+"&version="+version+"&delivery=download") ;
        
        if (cart_content == "already in cart")
        {
            alert("This item is already in your shopping cart. Please click the Checkout button on the right to checkout.");
        }
        else
        {
            document.getElementById('cart').innerHTML = cart_content; 
        }
    }
}   
   
function deleteCartItem(id,cookie,name)
{
    var delete_Prg = confirm("Are you sure that you want to remove " + name + " from your cart?");
    if(delete_Prg)    
    {   
        var cart_content = execAJAXCart("/remove_from_cart.php?id=" + id) ;
        document.getElementById('cart').innerHTML = cart_content; 
    }
}

function deleteCartItemFull(id,cookie,name)
{
    var delete_Prg = confirm("Are you sure that you want to remove " + name + " from your cart?");
    if(delete_Prg)    
    {
        var cart_content = execAJAXCart("https://www.dimensionsuite.com/remove_from_cart_full.php?id="+id) ;
        document.getElementById('cart').innerHTML = cart_content; 
    }
}

function updateQuantity(value,id)
{
    var cart_content = execAJAXCart("/update_quantity.php?id=" + id + "&value=" + value) ;
    
    document.getElementById('cart').innerHTML = cart_content; 

}
function updateQuantityFull(value,id)
{
    var cart_content = execAJAXCart("/update_quantity_full.php?id=" + id + "&value=" + value) ;
    
    document.getElementById('cart').innerHTML = cart_content; 

}
function checkTax(value)
{
    if(value == "Canada")
    {
        document.getElementById('taxes').style.display = 'table-row';
    }
    else
    {
        document.getElementById('taxes').style.display = 'none';
    }

}

function makeChanges()
{
    document.checkout_form.action = "/checkout/";
    document.checkout_form.submit();    
}

 function submit_order()
    {
        var problems = "";

        if (document.checkout_form.first_name.value == "")
        {
            problems = problems+"\n- Please enter your first name";
        }
        if (document.checkout_form.last_name.value == "")
        {
            problems = problems+"\n- Please enter your last name";
        }
        if (document.checkout_form.email.value == "")
        {
            problems = problems+"\n- Please enter your email address";
        }
        if (document.checkout_form.phone.value == "")
        {
            problems = problems+"\n- Please enter your phone number";
        }

        if (parseFloat(document.checkout_form.total_price.value) > 0)
        {
            if (document.checkout_form.address1.value == "")
            {
                problems = problems+"\n- Please fill the address 1 field";
            }
            if (document.checkout_form.city.value == "")
            {
                problems = problems+"\n- Please enter your city";
            }
            if (document.checkout_form.province.value == "")
            {
                problems = problems+"\n- Please enter your province/state";
            }
            if (document.checkout_form.country.options[document.checkout_form.country.selectedIndex].value == " ")
            {
                problems = problems+"\n- Please enter your country";
            }
            if (document.checkout_form.postal_code.value == "")
            {
                problems = problems+"\n- Please enter your postal code";
            }
            if (document.checkout_form.postal_code.value.length < 5)
            {
                problems = problems+"\n- Please enter a valid postal code";
            }
            if (document.checkout_form.payment_type.value == "")
            {
                problems = problems+"\n- Please select a payment type";
            }
         
            
            if(document.checkout_form.payment_type.value == 'cc')
            {
                if (document.checkout_form.cc_type.options[document.checkout_form.cc_type.selectedIndex].value == " ")
                {
                    problems = problems+"\n- Please select your card type";
                }
                if (document.checkout_form.cc_name.value == "")
                {
                    problems = problems+"\n- Please enter the name on your credit card";
                }
                if (document.checkout_form.cc_number.value == "")
                {
                    problems = problems+"\n- Please enter your credit card number";
                }
                if (document.checkout_form.cvv.value == "")
                {
                    problems = problems+"\n- Please enter the security code from the back of your card";
                }
                if (document.checkout_form.cc_month.options[document.checkout_form.cc_month.selectedIndex].value == " ")
                {
                    problems = problems+"\n- Please select your credit card expiry month";
                }
                if (document.checkout_form.cc_year.options[document.checkout_form.cc_year.selectedIndex].value == " ")
                {
                    problems = problems+"\n- Please select your credit card expiry year";
                }
            }
        }


        if (problems != "")
        {
            alert ("The following problems were encountered:\n"+problems+"\n\nPlease fix these problems and try again. Thanks!");
        }
        else
        {
            document.checkout_form.submit();
        }
    }