function SetDocumentDomain()
{
var domain = document.domain;
document.domain = domain.substring(domain.indexOf('.') + 1);
}
function CheckCompanyExistence(CompanyName)
{
_Common = new Common();
var url = "http://" + window.location.host + "/Utility.asmx";
var request = _Common.RemoteCallWebService(url, "business4less.com", "CheckCompanyExistence", "<CompanyName>" + CompanyName.toString() + "</CompanyName>");
try
{
if (request)
{
request.onreadystatechange = function() {
if (request.readyState == 4) {
_Common.GetBrowserIndependentElement("ProgressHolder").innerHTML = "";
if ((request.status.toString().substring(0, 1) != '4') && (request.status.toString().substring(0, 1) != '5')) {
var result = ParseXMLResponse(request);
if (result.split(",")[0] == "FALSE") {
ShowCompanyAvailable(result);
AddHandlerToNewSearchButton()
LoadRelatedProducts();
ShowBuyButton();
}
if (result.split(",")[0] == "TRUE") {
ShowCompanyNotAvailable(result);
AddHandlerToNewSearchButton();
UnLoadRelatedProducts();
HideBuyButton();
}
if (result.split(",")[0] == "UNDEFINED") {
ShowServiceErrorMessage();
AddHandlerToNewSearchButton();
UnLoadRelatedProducts();
}
}
else {
ShowServiceErrorMessage();
AddHandlerToNewSearchButton();
UnLoadRelatedProducts();
}
}
}
var sr = _Common.GetSOAPMethodCall("business4less.com", "CheckCompanyExistence", "<CompanyName>" + CompanyName.toString() + "</CompanyName>");
request.send(sr);
}
}
catch(exp)
{
window.alert(exp.toString());
}
}
function CheckOffshoreCompanyExistence(CompanyName, CompanyType)
{
_Common = new Common();
var url = "http://" + window.location.host + "/Utility.asmx";
var params = "<CompanyName>" + CompanyName.toString() + "</CompanyName>" + "<CompanyType>" + CompanyType.toString() + "</CompanyType>" + "<ProductID>" + parent.CurrentProductID.toString() + "</ProductID>";
var request = _Common.RemoteCallWebService(url, "business4less.com", "CheckOffshoreCompanyExistence", params);
try
{
if (request)
{
request.onreadystatechange = function() {
if( request.readyState == 4 )
{
_Common.GetBrowserIndependentElement("ProgressHolder").innerHTML = "";
if ((request.status.toString().substring(0,1) != '4') && (request.status.toString().substring(0,1) != '5'))
{
var result = _Common.ParseXMLResonse(request);
if (result.split(",")[0] == "FALSE")
{
ShowCompanyAvailable(result);
AddHandlerToNewSearchButton();
LoadRelatedProducts();
ShowBuyButton();
}
if (result.split(",")[0] == "TRUE")
{
ShowCompanyNotAvailable(result);
AddHandlerToNewSearchButton();
UnLoadRelatedProducts();
HideBuyButton();
}
if (result.split(",")[0] == "UNDEFINED")
{
ShowServiceErrorMessage();
AddHandlerToNewSearchButton();
}
}
else
{
ShowServiceErrorMessage();
AddHandlerToNewSearchButton();
}
}
}
var sr = _Common.GetSOAPMethodCall("business4less.com", "CheckOffshoreCompanyExistence", params);
request.send(sr);
}
}
catch(exp)
{
window.alert(exp.toString());
}
}
function CheckVATRegistration(VATName)
{
_Common = new Common();
var url = "http://" + window.location.host + "/Utility.asmx";
var params = "<VATName>" + VATName.toString() + "</VATName>";
var request = _Common.RemoteCallWebService(url, "business4less.com", "CheckVATRegistration", params);
try
{
if (request)
{
request.onreadystatechange = function() {
if( request.readyState == 4 )
{
_Common.GetBrowserIndependentElement("ProgressHolder").innerHTML = "";
if ((request.status.toString().substring(0,1) != '4') && (request.status.toString().substring(0,1) != '5'))
{
var result = request.responseXML.text;
if (result.split(",")[0] == "FALSE")
{
ShowCompanyAvailable(result);
AddHandlerToNewSearchButton();
LoadRelatedProducts();
ShowBuyButton();
}
if (result.split(",")[0] == "TRUE")
{
ShowCompanyNotAvailable(result);
AddHandlerToNewSearchButton();
UnLoadRelatedProducts();
HideBuyButton();
}
if (result.split(",")[0] == "UNDEFINED")
{
ShowServiceErrorMessage();
AddHandlerToNewSearchButton();
}
}
else
{
ShowServiceErrorMessage();
AddHandlerToNewSearchButton();
}
}
}
var sr = _Common.GetSOAPMethodCall("business4less.com", "CheckVATRegistration", params);
request.send(sr);
}
}
catch(exp)
{
window.alert(exp.toString());
}
}
function ShowServiceErrorMessage()
{
try
{
var MessageToDisplay = _Common.GetBrowserIndependentElement("Undefined").innerHTML;
_Common.GetBrowserIndependentElement("Undefined").innerHTML = MessageToDisplay + "...";
_Common.GetBrowserIndependentElement("Undefined").style.display = "block";
}
catch(exp)
{
window.alert(exp.toString());
}
}
function ShowCompanyNotAvailable(result)
{
try
{
var SearchMessage1 = _Common.GetBrowserIndependentElement("CompanyNotAvailable").innerHTML.replace("~COMPANY_NAME~", result.split(",")[1]);
var SearchMessage2 = SearchMessage1.replace("~COMPANY_NUMBER~", result.split(",")[2]);
_Common.GetBrowserIndependentElement("CompanyNotAvailable").innerHTML = SearchMessage2;
_Common.GetBrowserIndependentElement("CompanyNotAvailable").style.display = "block";
}
catch(exp)
{
window.alert(exp.toString());
}
}
function ShowCompanyAvailable(result)
{
try
{
var SearchMessage = _Common.GetBrowserIndependentElement("CompanyAvailable").innerHTML;
SearchMessage = SearchMessage.replace("~COMPANY_NAME~", result.split(",")[1]);
_Common.GetBrowserIndependentElement("CompanyAvailable").innerHTML = SearchMessage;
_Common.GetBrowserIndependentElement("CompanyAvailable").style.display = "block";
}
catch(exp)
{
window.alert(exp.toString());
}
}
function AddHandlerToNewSearchButton()
{
_Common = new Common();
try
{
_Common.GetBrowserIndependentElement("NewSearch").style.display = "none";
_Common.GetBrowserIndendentElementForDocument(parent.document, "img_chk").src = switchFolder() + "/cat_img/new/new_search.gif";
_Common.GetBrowserIndendentElementForDocument(parent.document, "img_chk").onMouseDown = function () {
parent.roll_over('img_chk', "../"+ switchFolder() +"/cat_img/new/new_search_h.gif");
};
_Common.GetBrowserIndendentElementForDocument(parent.document, "img_chk").onMouseUp = function(){
parent.roll_over('img_chk', "../"+ switchFolder() +"/cat_img/new/new_search.gif");
};
_Common.GetBrowserIndendentElementForDocument(parent.document, "img_chk").onMouseOut = function(){
parent.roll_over('img_chk', "../"+ switchFolder() +"/cat_img/new/new_search.gif");
};
_Common.GetBrowserIndendentElementForDocument(parent.document, "img_chk").onClick = function(){
parent.totalPriceRemover();
parent.ShowHideProductCommands('Product', parent.CurrentProductID, '?product_id=' + parent.CurrentProductID, null, 'search');
_Common.GetBrowserIndendentElementForDocument(parent.document, "img_chk").style.display = 'none';
};
}
catch(exp)
{
window.alert(exp.toString());
}
}
function ShowBuyButton()
{
_Common = new Common();
try
{
_Common.GetBrowserIndendentElementForDocument(parent.document, "img_buy").style.visibility = "visible";
}
catch(exp)
{
window.alert(exp.toString());
}
}
function HideBuyButton()
{
_Common = new Common();
try
{
_Common.GetBrowserIndendentElementForDocument(parent.document, "img_buy").style.visibility = "hidden";
}
catch(exp)
{
window.alert(exp.toString());
}
}
function LoadRelatedProducts()
{
try
{
parent.FinalRelatedProduct(parent.currentRelatedProId);
parent.Onrelatedpro();
}
catch(exp)
{
window.alert(exp.toString());
}
}
function UnLoadRelatedProducts()
{
_Common = new Common();
try
{
_Common.GetBrowserIndendentElementForDocument(parent.document, "RelatedProductDiv").style.display = 'none';
}
catch(exp)
{
window.alert(exp.toString());
}
}
function GetOffshoreCompanyTypes(ProductID, LinkCode)
{
_Common = new Common();
var url = "http://" + window.location.host + "/Utility.asmx";
var params = "<ProductID>" + ProductID.toString() + "</ProductID>" + "<LinkCode>" + LinkCode.toString() + "</LinkCode>"
var request = _Common.RemoteCallWebService(url, "business4less.com", "GetOffshoreCompanyTypes", params);
try
{
if (request)
{
request.onreadystatechange = function() {
if( request.readyState == 4 )
{
if ((request.status.toString().substring(0,1) != '4') && (request.status.toString().substring(0,1) != '5'))
{
var result = request.responseXML;
var xmlHeader = result.childNodes[0];
var soapEnvelope = result.childNodes[1];
var soapBody = soapEnvelope.childNodes[0];
var GetOffshoreCompanyTypesResponse = soapBody.childNodes[0];
var GetOffshoreCompanyTypesResult = GetOffshoreCompanyTypesResponse.childNodes[0];
var CompanyTypes = GetOffshoreCompanyTypesResult.childNodes[0];
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.loadXML(CompanyTypes.xml);
var ocResellerProduct = _Common.GetBrowserIndendentElementForDocument(parent.window.frames['frame_details'].document, 'ocResellerProduct');
for (i = 0; i < CompanyTypes.attributes.length; i++)
{
if (CompanyTypes.attributes[i].nodeName == "ResellerProduct")
{
ocResellerProduct.value = CompanyTypes.attributes[i].nodeValue;
}
}
var ocTypeContainer = _Common.GetBrowserIndendentElementForDocument(parent.window.frames['frame_details'].document, 'ocTypeContainer');
if (xmlDoc.childNodes(0).childNodes.length > 0)
{
if (xmlDoc.childNodes(0).childNodes(0).xml != null)
{
ocTypeContainer.innerHTML = xmlDoc.childNodes(0).childNodes(0).xml;
}
}
}
else
{
ShowServiceErrorMessage();
}
}
}
var sr = _Common.GetSOAPMethodCall("business4less.com", "GetOffshoreCompanyTypes", params);
request.send(sr);
}
}
catch(exp)
{
window.alert(exp.toString());
}
}
function GetUAgent() {
var UserAgnt = navigator.userAgent.toLowerCase();
var re = new RegExp("webkit/[5-9]|iemobile/[7-9]");
if (UserAgnt.indexOf('iphone') >= 0) {
return "iPhone";
}
else if (UserAgnt.indexOf('android') >= 0) {
return "android";
}
else if (UserAgnt.indexOf('blackberry') >= 0 && UserAgnt.match(re)) {
return "iPhone";
}
else if (UserAgnt.indexOf('symbianos/') >= 0 && UserAgnt.match(re)) {
return "iPhone";
}
else if (UserAgnt.indexOf('msie') >= 0 && UserAgnt.match(re)) {
return "iPhone"
}
else if (UserAgnt.indexOf('cfnetwork') >= 0 || UserAgnt.indexOf('darwin') >= 0) {
return "iPhone";
}
else if (queryStringNew('setapptype') == 'fbapp' && UserAgnt.match(re)) {
return "iPhone";
}
else {
return "";
}
}
function switchFolder() {
return "images";
}

