// correctly handle PNG transparency in IE 6.
function correct_png()
{
     var arVersion = navigator.appVersion.split("MSIE")
     var version = parseFloat(arVersion[1])
     if ((version >= 5.5) && (document.body.filters)) 
     {
       for(var j=0; j<document.images.length; j++)
       {
           var img = document.images[j]
           var imgName = img.src.toUpperCase()
           if (imgName.substring(imgName.length - 3, imgName.length) == "PNG" || imgName.substring(imgName.length - 3, imgName.length) == "png")
           {
             var imgID = (img.id) ? "id='" + img.id + "' " : ""
             var imgClass = (img.className) ? "class='" + img.className + "' " : ""
             var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
             var imgStyle = "display:inline-block;" + img.style.cssText 
             if (img.align == "left") imgStyle = "float:left;" + imgStyle
             if (img.align == "right") imgStyle = "float:right;" + imgStyle
             if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
             var strNewHTML = "<span " + imgID + imgClass + imgTitle
             + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
             + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
             + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
             img.outerHTML = strNewHTML
             j = j-1
           }
       }
     }
 }

//adjust content's position based on browser width
$(window).resize(function() {
 adjust_content_position();
});

function adjust_content_position() {
 //detect browser width
 var browser_width = $(document.body)[0].clientWidth;
 var content_width = $('#content').width();
 if (browser_width < content_width) {
     $('#content').css({ left: 0, margin: 0 });
 }
 else {
     $('#content').css({ left: "50%", "margin-left": "-" + content_width / 2 + "px" });
 }

 //detect browser height
// var browser_height = $(document.body)[0].clientHeight;
// var content_height = $('#content').height();
// 
// if( browser_height < content_height )
// {
//    if(browser_width < content_width) {
//         $('#content').css({ top: 0, left: 0, margin: 0 });
//     }
//     else
//     {
//        $('#content').css({ top: 0, left: "50%", "margin-left": "-" + content_width / 2 + "px"});
//     }
// }
// else
// {
//     var pos = (browser_width - content_width) / 2;
//     var max_offset = 30;
//     if (browser_width < content_width) {
//         if (pos < max_offset)
//             $('#content').css({ top: "50%", "margin-top": "-" + content_height / 2 + "px", left: 0, "margin-left": 0 });
//         else
//             $('#content').css({ top: 0, "margin-top": max_offset, left: 0, "margin-left": 0 });          
//     }
//     else {
//         if (pos < max_offset)
//             $('#content').css({ top: "50%", "margin-top": "-" + content_height / 2 + "px", left: "50%", "margin-left": "-" + content_width / 2 + "px" });
//         else
//             $('#content').css({ top: 0, "margin-top": max_offset, left: "50%", "margin-left": "-" + content_width / 2 + "px" });
//     }
// }

 
}

//click to show/hide a division
function show_div() {
    if (document.getElementById("money_back_details").style.display == "block") {
        document.getElementById("money_back_details").style.display = "none";
        document.getElementById("money_back_details_control").innerHTML = "Details&gt;&gt;";
    }
    else {
        document.getElementById("money_back_details").style.display = "block";
        document.getElementById("money_back_details_control").innerHTML = "Hide&lt;&lt;";
    }
}

function IsPositiveInteger(obj) {
    if (obj.value.match(/^[0-9]*[1-9][0-9]*$/)) {
        return true;
    }
    return false;
}

function IsValidEmail(obj) {
    var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$"
    var re = new RegExp(regu);
    if (obj.value.search(re) != -1) {
        return true;
    } else {
        return false;
    }
}	  


